Skip to content

Commit 77d96e7

Browse files
author
Takuma Yoshioka
committed
First commit
0 parents  commit 77d96e7

55 files changed

Lines changed: 2602 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
charset = utf-8
6+
7+
[*.html]
8+
indent_style = tab
9+
indent_size = 2

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.bundle
2+
.sass-cache
3+
/Gemfile.lock
4+
/crash.log
5+
/output
6+
/tmp
7+
/vendor

Checks

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deploy_check :internal_links
2+
#deploy_check :external_links
3+
deploy_check :mixed_content
4+
deploy_check :stale

Gemfile

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
source 'https://rubygems.org'
2+
3+
# static site generator
4+
gem 'nanoc', '~> 4'
5+
gem 'nanoc-toolbox'
6+
# required for `nanoc view`
7+
gem 'adsf'
8+
# required for `Nanoc::Helpers::XMLSitemap`
9+
gem 'builder'
10+
11+
# sass/scss
12+
gem 'sass'
13+
# pygments
14+
gem 'pygments.rb'
15+
# asciidoc
16+
gem 'asciidoctor'
17+
gem 'nanoc-asciidoctor'
18+
# pandoc
19+
#gem 'pandoc-ruby'
20+
21+
gem 'w3c_validators'

Rules

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
#!/usr/bin/env ruby
2+
3+
# Preprocess {{{1
4+
5+
preprocess do
6+
#create_tag_pages
7+
create_authors_htags
8+
create_archive_pages
9+
create_htag_pages('/tags/', items: articles)
10+
end
11+
12+
# }}}1
13+
14+
# sass partial.
15+
ignore '/**/_*'
16+
# vim tmp file.
17+
ignore '/**/.*.swp'
18+
19+
20+
compile '/articles/**/*.html' do
21+
filter :colorize_syntax, :default_colorizer => :pygmentsrb
22+
layout '/article.*'
23+
filter :relativize_paths, type: :html
24+
end
25+
26+
compile '/articles/**/*.adoc' do
27+
filter :asciidoctor, linkcss: true
28+
filter :colorize_syntax, :default_colorizer => :pygmentsrb
29+
layout '/article.*'
30+
filter :relativize_paths, type: :html
31+
end
32+
33+
compile '/assets/**/*.scss' do
34+
filter :sass, syntax: :scss
35+
filter :relativize_paths, type: :css
36+
end
37+
38+
compile '/members/*/*.adoc' do
39+
filter :asciidoctor, linkcss: true
40+
filter :colorize_syntax, :default_colorizer => :pygmentsrb
41+
layout '/member.*'
42+
filter :relativize_paths, type: :html
43+
end
44+
45+
compile '/tags/index.html.erb' do
46+
filter :erb
47+
layout '/page-base.*'
48+
filter :relativize_paths, type: :html
49+
end
50+
51+
compile '/tags/search.html' do
52+
filter :colorize_syntax, :default_colorizer => :pygmentsrb
53+
layout '/page-base.*'
54+
filter :relativize_paths, type: :html
55+
end
56+
57+
compile '/tags/**/*.html' do
58+
layout '/htag-page.*'
59+
filter :relativize_paths, type: :html
60+
end
61+
62+
compile '/tags/**/*.json' do
63+
layout '/htag-key.json'
64+
end
65+
66+
compile '/feed.xml' do
67+
filter :erb
68+
end
69+
70+
compile '/archives/*/*.html' do
71+
layout '/archive-by-year.html'
72+
filter :relativize_paths, type: :html
73+
end
74+
75+
compile '/archives/*/*/*.html' do
76+
layout '/archive-by-year-month.html'
77+
filter :relativize_paths, type: :html
78+
end
79+
80+
compile '/**/*.html' do
81+
layout '/page-base.html'
82+
filter :relativize_paths, type: :html
83+
end
84+
85+
compile '/**/*.html.erb' do
86+
filter :erb
87+
layout '/page-base.html'
88+
filter :relativize_paths, type: :html
89+
end
90+
91+
compile '/**/*.json.erb' do
92+
filter :erb
93+
end
94+
95+
compile '/**/*' do
96+
write item.identifier.to_s
97+
end
98+
99+
route '/articles/**/index.{html,adoc}' do
100+
yyyy,mm,dd,slug,relpath = /\/([0-9]{4})-([0-9]{2})-([0-9]{2})-([^\/]+)\/(.+)$/
101+
.match(@item.identifier.without_ext).captures
102+
"/#{yyyy}/#{mm}/#{dd}/#{slug}/#{relpath}.html"
103+
end
104+
105+
route '/articles/**/*.{html,adoc}' do
106+
yyyy,mm,dd,slug,relpath = /\/([0-9]{4})-([0-9]{2})-([0-9]{2})-([^\/]+)\/(.+)$/
107+
.match(@item.identifier.to_s).captures
108+
"/#{yyyy}/#{mm}/#{dd}/#{slug}/#{relpath}/index.html"
109+
# if item.identifier =~ '/index.*'
110+
# '/index.html'
111+
# else
112+
# item.identifier.without_ext + '/index.html'
113+
# end
114+
end
115+
116+
# /articles/**/yyyy-mm-dd-slug/* => /yyyy/mm/dd/slug/*
117+
route '/articles/**/*' do
118+
yyyy,mm,dd,slug,relpath = /\/([0-9]{4})-([0-9]{2})-([0-9]{2})-([^\/]+)\/(.+)$/
119+
.match(@item.identifier.to_s).captures
120+
"/#{yyyy}/#{mm}/#{dd}/#{slug}/#{relpath}"
121+
end
122+
123+
route '/assets/**/*.scss' do
124+
@item.identifier.without_ext + '.css'
125+
end
126+
127+
route '/assets/**/*' do
128+
@item.identifier.to_s
129+
end
130+
131+
route '/archives/**/*' do
132+
relpath = /^\/[^\/]*(\/.*)$/.match(@item.identifier.to_s).captures[0]
133+
relpath
134+
end
135+
136+
route '/members/**/*.adoc' do
137+
@item.identifier.without_ext + '/index.html'
138+
end
139+
140+
route '/**/*.{html,json}.erb' do
141+
@item.identifier.without_ext
142+
end
143+
144+
route '/**/*' do
145+
@item.identifier.to_s
146+
end
147+
148+
layout '/**/*', :erb
149+
150+
# vim: set foldmethod=marker :

content/articles.json.erb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
---
3+
<%=
4+
result = {}
5+
def to_iso8601(time)
6+
attribute_to_time(time).strftime('%FT%T%:z')
7+
end
8+
sorted_articles.each do |item|
9+
entry = {
10+
title: item[:title],
11+
created_at: to_iso8601(item[:created_at]),
12+
}
13+
#p attribute_to_time(item[:created_at])
14+
if val = item[:excerpt]
15+
entry['excerpt'] = val
16+
end
17+
if val = item[:updated_at]
18+
entry['updated_at'] = to_iso8601(val)
19+
end
20+
result[item.path] = entry
21+
end
22+
result.to_json
23+
%>
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
created_at: 2016-05-04T16:46:40+0900
3+
title: "これが……これが俺たちの新しいブログだ!"
4+
htags:
5+
- "ロ技研/おしらせ"
6+
kind: article
7+
authors:
8+
- "2014/larry/syskan"
9+
10+
excerpt: "新しいブログのお披露目です。"
11+
---
12+
13+
ブログとwikiを一新した話をします。
14+
15+
== TL;DR
16+
- link:https://blog.rogiken.org/[ブログ] と link:https://wiki.rogiken.org/[wiki] を新しく作ったので使ってください。
17+
- 良い機会なのでgitに慣れましょう。
18+
- 山奥の秘境での作業者にも優しい設計です。
19+
- vim使おうな!
20+
21+
== 獲得と喪失
22+
まず昨年のシス管の内部事情を3行で。
23+
24+
....
25+
「今のサーバOBさんに借りてるやつだからロ技研が自前で借りるべきじゃね?」
26+
「webは移行できたけどwikiがPHPバージョンとかいろいろ古すぎてつらい、これ保守するの厳しい」
27+
「そんなこんなのうちに旧サーバにアクセスできなくなってた……」
28+
....
29+
30+
うーん。 +
31+
とまあこういう経緯で、我々はサーバを手に入れ、そしてwikiを失ったのです。
32+
33+
== 征服感
34+
さて件のwikiというのはPHPで動くものでしたが、長らくアップデートされていなかったようで、もはや面倒な手順を踏まねばアップデートしてサーバを移行できないほど古いものでした。 +
35+
サーバ側に置いてあるファイルを見ても独自のwiki記法だし、wikiの内容を見るのにPHPの動くサーバを用意しなければいけないのも面倒です。
36+
37+
- PHPの動くwebサーバを用意しなければwikiを閲覧・編集できない
38+
- 独自wiki記法のせいで他への移行が面倒(移行先が制限されてしまう)
39+
40+
このような欠点を解消する方法を、私は知っていました。 +
41+
**静的サイトジェネレータ**と呼ばれるものです。
42+
43+
静的サイトジェネレータとは、ファイル群を変換してwebサイト(のhtml等)を生成するソフトウェアの一般名称です。 +
44+
その根底には、「webアプリ等でもないのに、単なるwebサイトを見るために裏でPHPなどの高度なプログラムを動かすのは、やりすぎである」という思想があります。 +
45+
wikiやブログも、単に閲覧する際にはデータがダイナミックに変化するものでもないし、純粋なwebサーバ以外の機能が必要になるのは**記事の投稿・編集等のタイミングだけ**です。 +
46+
なら、そのファイル変換とかの部分は外部のソフトウェアに任せた方が良いでしょう。 +
47+
**ひとつのことをうまくやるプログラムを協調させる**、いわゆるUNIX哲学みたいな発想です。 +
48+
**疎結合**にすることで、気に要らない部分だけを挿げ替えることが簡単にできるようになります。
49+
50+
この方針により、wiki(またはブログ)は大まかに次の部分に分割されることとなります。
51+
52+
- webサーバ
53+
- ソースファイルを変換してwiki/ブログのwebサイトを生成する
54+
- ソースファイルを特定の人々が編集できるようにする
55+
56+
これらのすべてを自前で用意するか、或いは簡単に別サービスに切り替え可能にすることで、「特定のサービスがなければ運用できない/運用が困難になる」という現象(いわゆる**link:https://ja.wikipedia.org/wiki/%E3%83%AD%E3%83%83%E3%82%AF%E3%82%A4%E3%83%B3%E5%8A%B9%E6%9E%9C[ロックイン]**)を防ぎ、システム全体を掌握することができるようになります。 +
57+
後の世代がメンテナンスしたり、別のサービスやソフトウェアに乗り換えたりするとき楽になるはずです。
58+
59+
=== webサーバ
60+
webサーバは、自前で動かしている link:https://www.rogiken.org/[ロ技研のwebページ] と同じものを使えます。 +
61+
副作用として、 rogiken.org のドメインを使えるようになります。
62+
63+
=== ソースファイルを変換するやつ
64+
これがまさに静的サイトジェネレータの役割です。 +
65+
諸事情(というか個人的な事情)があり、私個人のブログで使っていた link:http://nanoc.ws[nanoc] というものを利用することにしました。 +
66+
自作プラグインによる拡張も、生のRubyで書けるので容易です。
67+
(まあ、やりすぎると他への移行が面倒になりますが。)
68+
69+
また、nanocに限らず多くの静的サイトジェネレータは、プレビュー用に自前のサーバ機能を持っており、ソースファイルが手元にあればその完成形を見ることができます。 +
70+
つまり、**山奥のネットの繋がらない秘境に篭っても、手元にソースとRuby環境さえあればwikiやブログを閲覧・編集できる**ということです。
71+
72+
=== ソースファイルを特定の人々が編集できるようにするやつ
73+
多人数で開発し、競合をうまく解決し、テキストのバージョン管理に向いている。 +
74+
まさしくVCS(バージョン管理システム)です。
75+
76+
今回は、今をときめく**git**と、そのプラットフォームである**GitHub**を使うことにしました。 +
77+
wikiは link:https://github.com/titech-ssr/wiki.rogiken.org[こちら] 、ブログは link:https://github.com/titech-ssr/blog.rogiken.org[こちら] です。 +
78+
プログラマに限らず、何かの開発をする人はgit等を使えるに越したことはないので、部員の皆さんに慣れてもらう良い機会です。
79+
80+
また、これはgitではなくGitHubやGitLab等の機能ですが、Issueなどを使うことにより記事の内容に関するツッコミや質問なども管理できます。 +
81+
コメント機能に近いものです。 +
82+
攻撃的な鉞も、Issuesに投げればきっと誠心誠意対応してもらえることでしょう。
83+
84+
=== 連携
85+
今回、 link:https://jenkins.io/[Jenkins] というCI(継続的インテグレーション)ツールを使って、上で挙げた3要素の連携を行いました。 +
86+
部員の皆さんがGitHubへ更新をpushすれば、自動でファイル変換が実行され、webサーバのデータが更新されます。 +
87+
というわけで、これなら既存のwikiやブログと大して手間は変わらないだろうと思います。
88+
89+
=== その他
90+
皆さんが自分のお好きなエディタで記事を書けるようになります。 +
91+
link:https://asciidoclive.com/[AsciiDocLIVE] 等のサービスでWYSIWYGしても良いし、vimやEmacsで書いても良いでしょう。
92+
93+
執筆者だけでなく、利用者にも優しい仕組みになっています。 +
94+
「使われている画像を全てダウンロードしたい」なんて場合も、いちいちスクリプトを書いてクロールしたりせずとも、リポジトリから画像ファイルを抽出するだけです。 +
95+
検索だって、ダウンロードしてしまえばただのテキストですから、grep等好きなツールで検索することもできます。
96+
97+
== ファイル形式
98+
ファイル形式にはmarkdownでなく**AsciiDoc**を採用しました。 +
99+
markdownのように方言が沢山あるわけではなく、安心して残せる形式だからです。 +
100+
他にも、htmlの埋め込みが明示的に行えるとか、そもそもhtmlを使わずともmarkdownより遥かに表現力が高いとか、docbookの面影を残した設計になっていて技術文書に向いているとか、いろいろ理由はあります。
101+
102+
ともかく、これで**マウスポチポチかhtml直書きという究極の2択を回避**して記事を書けます。 +
103+
[small]#(まあ私はHTML直書き大好きですが……)#
104+
105+
== スタイル
106+
ページのHTMLテンプレートも自前で用意したものなので、弄り放題です。 +
107+
ダサいスタイルは変更しましょう。 +
108+
というかこのブログも今はショボい見た目ですが、そのうち何とかします。
109+
したいです。
110+
できればいいなぁ。
111+
112+
== まとめ
113+
- link:https://blog.rogiken.org/[ブログ] と link:https://wiki.rogiken.org/[wiki] を新しく作ったので使ってください。
114+
- 良い機会なのでgitに慣れましょう。
115+
- 山奥の秘境での作業者にも優しい設計です。
116+
- vim使おうな!

content/assets/css/_bootstrap3.min.scss

Lines changed: 6 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Styles for elements generated by asciidoctor.
3+
*/
4+
5+
div.title {
6+
$color: brown;
7+
/*font-size: 125%;*/
8+
border-left: 0.75em solid $color;
9+
padding-left: 0.5em;
10+
color: $color;
11+
}
12+
div.admonitionblock {
13+
padding: 0.2rem 0.5rem;
14+
margin-bottom: 10px; // Same as bottom margin of `p`.
15+
>table {
16+
margin-bottom: initial;
17+
}
18+
td.icon {
19+
display: none;
20+
}
21+
22+
&.caution {
23+
// f071: fa-exclamation-triangle, fa-warning
24+
@include admon(#EA5, #f8f0d0, "\f071");
25+
}
26+
&.important {
27+
// f06a: fa-exclamation-circle
28+
@include admon(#EA5, #f8f0d0, "\f06a");
29+
}
30+
&.note {
31+
// f24a: fa-sticky-note-o
32+
// f05a: fa-info-circle
33+
@include admon(#5be, #e8f0f8, "\f05a ");
34+
}
35+
&.tip {
36+
// f0eb: fa-lightbulb-o
37+
@include admon(#5BE, #e8f0f8, "\f0eb");
38+
}
39+
&.warning {
40+
// f06d: fa-fire
41+
@include admon(red, #FEE, "\f06d");
42+
}
43+
}
44+
/*
45+
* bootstrap3ではdiv.quoteblock>blockquoteのmargin-bottomとpadding-bottomが20pxである。
46+
* asciidoctorではattributionがblockqote要素の外に出るので、
47+
* 引用とattributionの間が空きすぎないよう間隔を縮める。
48+
*/
49+
div.quoteblock>blockquote+.attribution {
50+
margin-top: -15px;
51+
margin-bottom: 20px;
52+
}

0 commit comments

Comments
 (0)