rake -> commands, full site support
parent
cb5c0a256c
commit
4695d4b0ce
3
Rakefile
3
Rakefile
|
@ -1,3 +0,0 @@
|
|||
require 'nanoc/tasks'
|
||||
|
||||
Dir['tasks/**/*.rake'].sort.each { |rakefile| load rakefile}
|
|
@ -4,4 +4,4 @@
|
|||
|
||||
source ~/.zsh/path.sh
|
||||
|
||||
grep -roP "http://.*" content | backup-urls
|
||||
./extract_links.sh | backup-urls
|
||||
|
|
|
@ -11,7 +11,7 @@ hosts = [
|
|||
"video.google.com",
|
||||
]
|
||||
|
||||
urls = `grep -horP 'http://.*(#{hosts.join "|"})[^\"]*\\b' content/ | sort -u`
|
||||
urls = `./extract_links.sh | grep -P 'https?://.*(#{hosts.join "|"})[^\"]*\\b' | sort -u`
|
||||
|
||||
Dir.chdir "video-backup"
|
||||
urls.split.each do |url|
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
usage 'backup'
|
||||
summary 'backup external data'
|
||||
description 'Backups external data.'
|
||||
|
||||
run do |_, _, cmd|
|
||||
# backup everything
|
||||
%w(links videos).each do |s|
|
||||
cmd.command_named(s).run([])
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
usage 'links'
|
||||
summary 'backup links'
|
||||
description 'Backups all external links in content files.'
|
||||
|
||||
run do
|
||||
system "./backup-links.sh"
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
usage 'videos'
|
||||
summary 'backup videos'
|
||||
description 'Backups all videos in content files.'
|
||||
|
||||
run do
|
||||
system "./backup-videos.rb"
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
# add list of all sites so that this file does something useful
|
||||
usage 'compress'
|
||||
summary 'compresses site(s)'
|
||||
description 'Compresses all web files in given site(s).'
|
||||
|
||||
required :s, :sites, 'sites'
|
||||
|
||||
module Nanoc::CLI::Commands
|
||||
class Compress < ::Nanoc::CLI::CommandRunner
|
||||
def run
|
||||
sites_arg(options[:sites]).each do |site|
|
||||
system "./compress-html.sh #{site}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
runner Nanoc::CLI::Commands::Compress
|
|
@ -0,0 +1,36 @@
|
|||
# add list of all sites so that this file does something useful
|
||||
usage 'publish'
|
||||
summary 'publish site(s)'
|
||||
description 'Publishes site(s) to all online targets.'
|
||||
|
||||
flag :p, :'pretend', 'pretend to publish'
|
||||
required :s, :sites, 'sites'
|
||||
|
||||
module Nanoc::CLI::Commands
|
||||
class Publish < ::Nanoc::CLI::CommandRunner
|
||||
def run
|
||||
m = method(options[:pretend] ? :puts : :system)
|
||||
|
||||
# push changes to github
|
||||
m.call "git push origin"
|
||||
|
||||
sites_arg(options[:sites]).each do |site|
|
||||
puts "publishing site: #{site}"
|
||||
|
||||
# clean unneeded files
|
||||
m.call "nanoc prune -s #{site} --yes"
|
||||
|
||||
# compile site to ensure a usable state
|
||||
m.call "nanoc compile -s #{site}"
|
||||
|
||||
# compress files
|
||||
m.call "nanoc compress -s #{site}"
|
||||
|
||||
# deploy files
|
||||
m.call "nanoc deploy -t default -s #{site}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
runner Nanoc::CLI::Commands::Publish
|
|
@ -1,57 +1,87 @@
|
|||
# support for site-specific configs
|
||||
|
||||
# add option to all nanoc commands
|
||||
Nanoc::CLI.root_command.modify do
|
||||
required :s, :site, "custom site" do |site, _|
|
||||
puts "set site: #{site}, adding config..."
|
||||
# built-in cmds than need a site option
|
||||
site_cmds = [
|
||||
'(auto)?compile',
|
||||
'create_\w+',
|
||||
'debug',
|
||||
'deploy',
|
||||
'prune',
|
||||
'update',
|
||||
'view',
|
||||
'watch',
|
||||
]
|
||||
|
||||
# make site globally accessibly
|
||||
$site = site
|
||||
|
||||
module ::Nanoc
|
||||
class Site
|
||||
alias old_build_config build_config
|
||||
|
||||
def build_config(dir_or_config_hash)
|
||||
# build default
|
||||
old_build_config(dir_or_config_hash)
|
||||
# add option to all nanoc commands that operate on sites
|
||||
Nanoc::CLI.root_command.commands.select do |cmd|
|
||||
cmd.name =~ /^(#{site_cmds.join("|")})/
|
||||
end.each do |cmd|
|
||||
cmd.modify do
|
||||
required :s, :site, "custom site" do |site, _|
|
||||
puts "set site: #{site}"
|
||||
|
||||
puts "extend config..."
|
||||
|
||||
@config[:output_dir] = "out/#{$site}"
|
||||
# make site globally accessibly
|
||||
$site = site
|
||||
|
||||
module ::Nanoc
|
||||
class Site
|
||||
alias old_build_config build_config
|
||||
|
||||
@config[:data_sources] = [{
|
||||
type: "filesystem_customizable",
|
||||
source_dir: ["content_#{$site}"],
|
||||
items_root: "/",
|
||||
layouts_root: "/",
|
||||
config: {},
|
||||
}]
|
||||
@config[:data_sources].map! { |ds| ds.symbolize_keys }
|
||||
def build_config(dir_or_config_hash)
|
||||
# build default
|
||||
old_build_config(dir_or_config_hash)
|
||||
|
||||
ssh =
|
||||
if $site == "muflax"
|
||||
$site
|
||||
else
|
||||
"muflax-#{$site}"
|
||||
end
|
||||
|
||||
@config[:deploy] = {
|
||||
default: {
|
||||
dst: "#{ssh}:/home/public",
|
||||
options: ['-gpPrtvz', '--delete'],
|
||||
kind: "rsync"
|
||||
puts "extending config..."
|
||||
|
||||
@config[:output_dir] = "out/#{$site}"
|
||||
|
||||
@config[:data_sources] = [{
|
||||
type: "filesystem_customizable",
|
||||
source_dir: ["content_#{$site}"],
|
||||
items_root: "/",
|
||||
layouts_root: "/",
|
||||
config: {},
|
||||
}]
|
||||
@config[:data_sources].map! { |ds| ds.symbolize_keys }
|
||||
|
||||
ssh =
|
||||
if $site == "muflax"
|
||||
$site
|
||||
else
|
||||
"muflax-#{$site}"
|
||||
end
|
||||
|
||||
@config[:deploy] = {
|
||||
default: {
|
||||
dst: "#{ssh}:/home/public",
|
||||
options: ['-gpPrtvz', '--delete'],
|
||||
kind: "rsync"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@config[:watcher][:dirs_to_watch] << "content_#{$site}"
|
||||
@config[:watcher][:dirs_to_watch] << "content_#{$site}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# helper function
|
||||
module Nanoc::CLI
|
||||
class CommandRunner
|
||||
def all_sites
|
||||
Dir['content_*'].map{|d| d.gsub(/^content_/, '')}.sort
|
||||
end
|
||||
|
||||
# lots of commands use -s now, so simplify its use
|
||||
def sites_arg sites
|
||||
sites.nil? ? all_sites : sites.split(",")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# add list of all sites so that this file does something useful
|
||||
# show list of all sites so that this file does something useful
|
||||
usage 'sites'
|
||||
summary 'prints all available sites'
|
||||
description 'Prints all sites that can be used via -s SITE.'
|
||||
|
@ -59,8 +89,7 @@ description 'Prints all sites that can be used via -s SITE.'
|
|||
module Nanoc::CLI::Commands
|
||||
class Sites < ::Nanoc::CLI::CommandRunner
|
||||
def run
|
||||
self.require_site
|
||||
puts "sites: #{Dir['content_*'].map{|d| d.gsub(/^content_/, '')}.join ', '}"
|
||||
puts "sites: #{all_sites.join ', '}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
usage 'wips'
|
||||
summary 'find all :wip articles'
|
||||
description 'Finds all drafts, i.e. articles marked as :wip.'
|
||||
|
||||
run do |opts, args, cmd|
|
||||
system "grep -l ':wip' content*/**/*.mkd"
|
||||
end
|
|
@ -4,9 +4,14 @@
|
|||
|
||||
setopt RE_MATCH_PCRE
|
||||
|
||||
echo "compressing 'out'..."
|
||||
if [[ -z $1 ]]; then
|
||||
echo "usage: $0 site"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for f in out/**/*(.); do
|
||||
echo "compressing site: $1..."
|
||||
|
||||
for f in out/$1/**/*(.); do
|
||||
if [[ $f =~ "\.(html|css|xml|js)$" ]]; then
|
||||
gzip --best -f -v -c "$f" > "$f.gz"
|
||||
fi
|
||||
|
|
|
@ -5,6 +5,11 @@ is_hidden: true
|
|||
<!-- personal links -->
|
||||
[Antinatalism Tumblr]: http://antinatalism.tumblr.com/
|
||||
[Beeminder]: https://www.beeminder.com/muflax/goals/
|
||||
[Beeminder anki]: https://www.beeminder.com/muflax/goals/anki
|
||||
[Beeminder fitocracy]: https://www.beeminder.com/muflax/goals/fitocracy
|
||||
[Beeminder fume]: https://www.beeminder.com/muflax/goals/fume
|
||||
[Beeminder daily]: https://www.beeminder.com/muflax/goals/dailylog
|
||||
[Beeminder weight]: https://www.beeminder.com/muflax/goals/weight
|
||||
[Blog]: http://blog.muflax.com
|
||||
[GPG Key]: /muflax.asc
|
||||
[Google+]: https://plus.google.com/105665518912548939532
|
||||
|
@ -59,6 +64,7 @@ is_hidden: true
|
|||
[LW bipolar]: http://lesswrong.com/lw/6nb/ego_syntonic_thoughts_and_values/4igy
|
||||
[LW protect]: http://lesswrong.com/lw/nb/something_to_protect/
|
||||
[LW words]: http://lesswrong.com/lw/od/37_ways_that_words_can_be_wrong/
|
||||
[LW sequences]: http://wiki.lesswrong.com/wiki/Sequences
|
||||
[LessWrong]: http://lesswrong.com
|
||||
[Look, Ma; No Hands!]: http://www.semanticrestructuring.com/lookma.php
|
||||
[Moldbug Left Right]: http://unqualified-reservations.blogspot.com/2008/06/olxi-truth-about-left-and-right.html
|
||||
|
@ -97,6 +103,46 @@ is_hidden: true
|
|||
[shamus bible]: http://www.shamusyoung.com/twentysidedtale/?p=12768&cpage=1#comment-231273
|
||||
[suffering per kg]: http://www.utilitarian-essays.com/suffering-per-kg.html
|
||||
[tripzine]: http://www.tripzine.com/listing.php?smlid=268
|
||||
[Wolfire]: http://www.youtube.com/playlist?list=PLA17B3FAA1DA374F3&feature=plcp
|
||||
[honeybadger]: http://www.youtube.com/watch?v=4r7wHMg5Yjg
|
||||
[AJATT]: http://www.alljapaneseallthetime.com/
|
||||
[Technium]: http://www.kk.org/books/what-technology-wants.php
|
||||
[PihloBro]: http://www.philosophybro.com/
|
||||
[reblog]: http://www.youtube.com/watch?feature=player_detailpage&v=roTrYCUhOu0#t=86s
|
||||
[Meaningness]: https://meaningness.wordpress.com/
|
||||
[Tao]: http://www.beatrice.com/TAO.txt
|
||||
[Good Job]: http://www.youtube.com/watch?v=-yNhl8wT3Pc
|
||||
[Jhana Arc]: http://thehamiltonproject.blogspot.com/2011/01/yogi-toolbox-riding-jhanic-arc-via.html
|
||||
[Wasteland Kickstarter]: http://www.kickstarter.com/projects/inxile/wasteland-2
|
||||
[Howto Jhana]: http://www.leighb.com/jhana3.htm
|
||||
[LW luke/ben]: http://lesswrong.com/r/discussion/lw/aw7/muehlhausergoertzel_dialogue_part_1/
|
||||
[LeechBlock]: https://addons.mozilla.org/en-US/firefox/addon/leechblock/
|
||||
[Pali 02]: http://www.accesstoinsight.org/tipitaka/dn/dn.02.0.than.html
|
||||
[Cookie Monster Nom]: https://www.youtube.com/watch?v=Cqz9ZXUoUcE
|
||||
[maggots image]: http://www.snopes.com/photos/medical/maggots.asp
|
||||
[maggots head]: http://www.liveleak.com/view?i=8d5_1219029078
|
||||
[Eva Eat]: https://www.youtube.com/watch?v=rlobzMvkm4w
|
||||
[MP comfy]: https://www.youtube.com/watch?v=CSe38dzJYkY
|
||||
[Logic Core]: https://www.youtube.com/watch?v=-iAUwamHTM4
|
||||
[Sister Epilogue]: http://theviewfromhell.blogspot.de/2010/12/living-in-epilogue-social-policy-as.html
|
||||
[bible fault]: http://www.biblegateway.com/passage/?search=John+19%3A6&version=NKJV
|
||||
[Harris Free Will]: https://www.youtube.com/watch?v=pCofmZlC72g
|
||||
[Unicorn Magic]: https://www.youtube.com/watch?v=qqvRrKcEhD4
|
||||
[TreeTagger]: http://www.ims.uni-stuttgart.de/projekte/corplex/TreeTagger/
|
||||
[Words dict]: http://users.erols.com/whitaker/words.htm
|
||||
[Perseus]: http://www.perseus.tufts.edu/hopper/
|
||||
[Schmidhuber Creativity]: http://vimeo.com/7441291
|
||||
[verboten]: https://www.youtube.com/watch?v=OfPCfqnQlpM
|
||||
[Wasteland Obsidian]: http://www.rockpapershotgun.com/2012/03/30/obisidian-to-co-develop-wasteland-2-on-one-condition/
|
||||
[Age of Decadence]: http://www.irontowerstudio.com/
|
||||
[Somuncu]: https://www.youtube.com/watch?v=d9qciD3sy2w
|
||||
[SMBC death]: https://www.youtube.com/watch?v=ARlTV1ZGJk8
|
||||
[Living Prayer]: http://www.godtube.com/watch/?v=7LL7D7NX
|
||||
[Assyriche]: https://www.youtube.com/watch?v=EcInBA4FlU8
|
||||
[Exorcist]: https://www.youtube.com/watch?v=Jvhl4At6AX8
|
||||
[99 hearts]: http://www.youtube.com/watch?v=dKm_7eOoGFc
|
||||
[Paint It Black]: https://www.youtube.com/watch?v=fPVUa29kHu8
|
||||
[Final Destination]: https://www.youtube.com/watch?v=O-7gmds2njg
|
||||
|
||||
<!-- Wikipedia articles (and similar) -->
|
||||
[A-theory]: http://en.wikipedia.org/wiki/A-series_and_B-series
|
||||
|
@ -114,7 +160,7 @@ is_hidden: true
|
|||
[Convict Conditioning]: http://www.dragondoor.com/b41/
|
||||
[Core Dump]: http://en.wikipedia.org/wiki/Core_dump
|
||||
[Crocker's Rules]: http://wiki.lesswrong.com/wiki/Crocker%27s_rules
|
||||
[DXM]: http://en.wikipedia.org/wiki/DXM
|
||||
[DXM]: https://www.erowid.org/chemicals/dxm/faq/dxm_faq.shtml
|
||||
[Desirism]: http://commonsenseatheism.com/?p=2982
|
||||
[Desirism]: http://omnisaffirmatioestnegatio.wordpress.com/2010/04/30/desirism-a-quick-dirty-sketch/
|
||||
[Discordianism]: http://en.wikipedia.org/wiki/Discordianism
|
||||
|
@ -176,6 +222,30 @@ is_hidden: true
|
|||
[al-Ghazali]: http://en.wikipedia.org/wiki/Al-Ghazali
|
||||
[quark]: http://en.wikipedia.org/wiki/Quark_(cheese)
|
||||
[schächten]: http://en.wikipedia.org/wiki/Shechita
|
||||
[Pali Canon]: https://en.wikipedia.org/wiki/Pali_canon
|
||||
[Nirodha Samapatti]: http://web.mac.com/danielmingram/iWeb/Daniel%20Ingram%27s%20Dharma%20Blog/The%20Blook/2CECD5EA-6058-4428-8DDD-002856C2E28A.html
|
||||
[Kenosis]: http://en.wikipedia.org/wiki/Kenosis
|
||||
[Stromberg]: http://en.wikipedia.org/wiki/Stromberg_%28TV_series%29
|
||||
[A Serious Man]: http://en.wikipedia.org/wiki/A_serious_man
|
||||
[subs2srs]: http://rtkwiki.koohii.com/wiki/Subs2srs
|
||||
[MCD]: http://www.alljapaneseallthetime.com/blog/series/mcd-revolution
|
||||
[Book of the Dead]: https://en.wikipedia.org/wiki/Bardo_Thodol
|
||||
[Oreo]: https://en.wikipedia.org/wiki/Oreo
|
||||
[Dirk Gently TV]: https://en.wikipedia.org/wiki/Dirk_Gently_%28TV_series%29
|
||||
[Aeron]: https://en.wikipedia.org/wiki/Aeron_chair
|
||||
[10 Precepts]: https://en.wikipedia.org/wiki/Five_Precepts#Ten_Precepts
|
||||
[unsupervised universe]: http://wiki.lesswrong.com/wiki/Unsupervised_universe
|
||||
[Missionary Paradox]: http://everything2.com/title/Missionary+Paradox
|
||||
[Wu Wei]: https://en.wikipedia.org/wiki/Wu_wei
|
||||
[Shangri-la diet]: https://en.wikipedia.org/wiki/The_Shangri-La_Diet
|
||||
[Olsenbande]: https://en.wikipedia.org/wiki/Olsen_Gang
|
||||
[BG2]: https://en.wikipedia.org/wiki/Baldur%27s_Gate_II:_Shadows_of_Amn
|
||||
[quadtree]: https://en.wikipedia.org/wiki/Quadtree
|
||||
[Faust]: https://en.wikipedia.org/wiki/Goethe%27s_Faust
|
||||
[Kant]: https://en.wikipedia.org/wiki/Immanuel_Kant
|
||||
|
||||
<!-- tweets -->
|
||||
[Twitter pali]: https://twitter.com/#!/muflax/status/66635052242567168
|
||||
|
||||
<!-- internal links -->
|
||||
[RSS]: /rss.xml
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/zsh
|
||||
# Copyright muflax <mail@muflax.com>, 2012
|
||||
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
|
||||
|
||||
grep -ahorP '(https?[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]' content_*
|
||||
|
|
@ -2,9 +2,14 @@
|
|||
# Copyright muflax <mail@muflax.com>, 2012
|
||||
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>
|
||||
|
||||
if [[ -z $1 ]]; then
|
||||
echo "usage: $0 site"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# start a screen session and set up basic tools
|
||||
screen -dmS nanoc nanoc view
|
||||
screen -S nanoc -X screen -t watch 1 nanoc watch
|
||||
screen -dmS nanoc nanoc -s $1 view
|
||||
screen -S nanoc -X screen -t watch 1 nanoc -s 1 watch
|
||||
screen -S nanoc -X screen -t mc 2 zsh -c mc
|
||||
screen -S nanoc -X screen 3 zsh
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# backup all important external data
|
||||
|
||||
namespace :backup do
|
||||
desc "backup links"
|
||||
task :links do
|
||||
system "./backup-links.sh"
|
||||
end
|
||||
|
||||
desc "backup videos"
|
||||
task :videos do
|
||||
system "./backup-videos.rb"
|
||||
end
|
||||
end
|
||||
|
||||
desc "backup everything"
|
||||
task :backup => ['backup:links', 'backup:videos']
|
|
@ -1,12 +0,0 @@
|
|||
# compress all text files in out/ to save on traffic
|
||||
|
||||
namespace :compress do
|
||||
desc "compress html (and related) files"
|
||||
task :html do
|
||||
system "./compress-html.sh"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "compress everything"
|
||||
task :compress => ['compress:html']
|
|
@ -1,6 +0,0 @@
|
|||
# some misc helper functions
|
||||
|
||||
desc "find all :wip articles"
|
||||
task :wips do
|
||||
system "grep -l ':wip' content/**/*.mkd"
|
||||
end
|
|
@ -1,21 +0,0 @@
|
|||
# make all changes public
|
||||
|
||||
namespace :publish do
|
||||
desc "push changes to github"
|
||||
task :push do
|
||||
system "git push origin"
|
||||
end
|
||||
|
||||
desc "compile site"
|
||||
task :compile do
|
||||
system "nanoc compile"
|
||||
end
|
||||
|
||||
desc "push all files to website"
|
||||
task :deploy => [:compile, "compress"] do
|
||||
system "nanoc deploy -t default"
|
||||
end
|
||||
end
|
||||
|
||||
desc "publish complete site"
|
||||
task :publish => ['publish:push', 'publish:deploy']
|
Loading…
Reference in New Issue