Last active
April 7, 2021 01:12
-
-
Save 3110/cecf53ccade259f63f2fb3370174fe1c to your computer and use it in GitHub Desktop.
Scrapboxで新たに作成したプロジェクトに自分のページとsettingsページを追加する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import json | |
import urllib.parse | |
import subprocess | |
OPEN_CMD = 'start' # Windows | |
# OPEN_CMD = 'open' # macOS | |
USER_NAME = 'saitotetsuya' | |
SCRAPBOX_URL_FORMAT = 'https://scrapbox.io/{project}/{title}?body={body}' | |
SETUP_PROJECT_DATA = { # インポートデータと同じ書式 | |
"pages": [ | |
{ | |
"title": USER_NAME, | |
"lines": [ | |
USER_NAME, | |
"[https://gyazo.com/6d77b0f2f2514ab097478752ea4ac494]", | |
"code:script.js", | |
" import \"/api/code/saitotetsuya/saitotetsuya/script.js\";" | |
] | |
}, | |
{ | |
"title": "settings", | |
"lines": [ | |
"settings", | |
"code:style.css", | |
" @import \"/api/code/saitotetsuya/settings/style.css\";" | |
] | |
} | |
] | |
} | |
def setup_project(name): | |
for p in SETUP_PROJECT_DATA['pages']: | |
body = urllib.parse.quote('\n'.join(p['lines'][1:])) | |
title = urllib.parse.quote(p['title']) | |
url = SCRAPBOX_URL_FORMAT.format(project=name, title=title, body=body) | |
subprocess.call([OPEN_CMD, url], shell=True) | |
if __name__ == '__main__': | |
import argparse | |
parser = argparse.ArgumentParser() | |
parser.add_argument('project', help='プロジェクト名') | |
args = parser.parse_args() | |
setup_project(args.project) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment