Last active
May 14, 2017 16:24
-
-
Save tioover/6d11f181ff58af2a95ebd5d3097a91c1 to your computer and use it in GitHub Desktop.
Revisions
-
tioover revised this gist
May 14, 2017 . 1 changed file with 18 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -6,13 +6,27 @@ import sys import datetime # Settings POSTS_DIR = '_posts' TARGET_DIR = '_site' OPEN_EDITOR_COMMAND = 'open' TIMEZONE = '+0800' # Maybe shoud use pytz? SSH = "[email protected]:/var/www/ioover.net/html/" run = os.system def depoly(): ''' Your depoly script.''' run('JEKYLL_ENV=production bundle exec jekyll build') print("=> JEKYLL DONE") run('npm run webpack') print("=> WEBPACK DONE") run('rsync -rav {target}/* {dest}'.format(target=TARGET_DIR, dest=SSH)) print("=> RSYNC DONE") print('ALL DONE') def new_post(filename, title=""): ''' Create new post. ''' @@ -26,7 +40,7 @@ def new_post(filename, title=""): typora-copy-images-to: ../media ---'''.format(title, now.strftime('%Y-%m-%d %H:%M:%S '+TIMEZONE)) filename = now.strftime('%Y-%m-%d-') + filename + '.md' path = os.path.join(POSTS_DIR, filename) if not os.path.exists(path): with open(path, mode='w', encoding='utf-8') as new: new.write(source) @@ -43,7 +57,6 @@ def new_post(filename, title=""): elif len(arg) == 3: new_post(arg[1], title=arg[2]) elif arg[0] == 'depoly': depoly() else: run('bundle exec jekyll ' + ' '.join(arg)) -
tioover created this gist
May 13, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ #!/usr/bin/env python3 ''' Simple Jekyll site manage script. ''' import os import sys import datetime OPEN_EDITOR_COMMAND = "open" TIMEZONE = '+0800' # Maybe shoud use pytz? def depoly(): ''' Your depoly script.''' pass def new_post(filename, title=""): ''' Create new post. ''' now = datetime.datetime.now() source = '''--- layout: post title: "{}" date: {} category: typora-root-url: ../ typora-copy-images-to: ../media ---'''.format(title, now.strftime('%Y-%m-%d %H:%M:%S '+TIMEZONE)) filename = now.strftime('%Y-%m-%d-') + filename + '.md' path = os.path.join('_posts', filename) if not os.path.exists(path): with open(path, mode='w', encoding='utf-8') as new: new.write(source) else: print('File {} already exists!'.format(filename)) os.popen(OPEN_EDITOR_COMMAND + " " + path) if __name__ == '__main__': arg = sys.argv[1:] if arg[0] == 'post': if len(arg) == 2: new_post(arg[1]) elif len(arg) == 3: new_post(arg[1], title=arg[2]) elif arg[0] == 'depoly': os.system('JEKYLL_ENV=production bundle exec jekyll build') depoly() else: os.system('bundle exec jekyll ' + ' '.join(arg))