Last active
February 4, 2017 05:44
-
-
Save drakeguan/9a641e768aef4d13781022a500b79c37 to your computer and use it in GitHub Desktop.
Warp up of gradually conversion of old blogs to Hugo preferred ones.
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
This gist contains several random scripts I used to convert old blogs to Huge way~ |
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
import os | |
def get_url_from_node(filename): | |
with open(filename) as fin: | |
for line in fin: | |
if 'refresh' in line: | |
return line[42:-5] | |
#iname = 'www/node/1/index.html' | |
#print get_url_from_node(iname) | |
for f in sorted(os.listdir('www/node')): | |
ff = 'www/node/' + f + '/index.html' | |
f2 = get_url_from_node(ff) | |
f3 = 'content'+f2[:-1]+'.md' | |
alias = 'node/%s/' % f | |
#print f3, alias | |
with open(f3) as fin: | |
lines = fin.readlines() | |
for idx, line in enumerate(lines[1:]): | |
if line.startswith('+++'): | |
break | |
else: | |
print 'ohoh...', f3 | |
continue | |
lines.insert(idx, 'aliases = [\n') | |
lines.insert(idx+1, ' "/node/%s/"\n' % f) | |
lines.insert(idx+2, ']\n') | |
with open(f3, 'w') as fout: | |
fout.writelines(lines) |
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
# Update blogs. Use "{{< relref" to replace all cross-references. | |
find: \(/(blog/2[^ ]*)/[^/]*?\) | |
replace: ({{< relref "\1.md" >}}) | |
in: sublime text (cause vim crashes all the time! qq~) |
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
# vim: set sw=2 sts=2 ts=2 et: | |
# | |
### Replace ooxx stuff to fit your settings. ### | |
# | |
# This references a standard debian container from the | |
# Docker Hub https://registry.hub.docker.com/_/debian/ | |
# Read more about containers on our dev center | |
# http://devcenter.wercker.com/docs/containers/index.html | |
box: debian | |
# This is the build pipeline. Pipelines are the core of wercker | |
# Read more about pipelines on our dev center | |
# http://devcenter.wercker.com/docs/pipelines/index.html | |
build: | |
# Steps make up the actions in your pipeline | |
# Read more about steps on our dev center: | |
# http://devcenter.wercker.com/docs/steps/index.html | |
steps: | |
- arjen/hugo-build: | |
version: "0.18.1" | |
force_install: true | |
deploy: | |
steps: | |
- install-packages: | |
packages: ssh-client rsync | |
# packages: openssh-client rsync | |
- add-to-known_hosts: | |
hostname: oo.xx.org | |
fingerprint: oo:xx:oo:xx:... | |
local: true | |
- wercker/mktemp@1.0.0: | |
envvar: TEMPORARY_FILE | |
- wercker/create-file@0.9.8: | |
name: write key | |
filename: $TEMPORARY_FILE | |
content: $SHERLOCK_PRIVATE | |
overwrite: true | |
hide-from-log: true | |
- script: | |
name: deploy to sherlock | |
code: rsync -avz -e "ssh -l root -i $TEMPORARY_FILE -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" public/ oo.xx.org:/www/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment