memorack 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +28 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +108 -0
- data/Rakefile +13 -0
- data/VERSION +1 -0
- data/bin/memorack +9 -0
- data/etc/tools/update_version.rb +14 -0
- data/lib/memorack/cli.rb +263 -0
- data/lib/memorack/locales/en.yml +7 -0
- data/lib/memorack/locales/ja.yml +7 -0
- data/lib/memorack/mdmenu.rb +185 -0
- data/lib/memorack/memoapp.rb +350 -0
- data/lib/memorack/sinatra-mustache.rb +13 -0
- data/lib/memorack/template/.gitignore +12 -0
- data/lib/memorack/template/.powenv +1 -0
- data/lib/memorack/template/Gemfile +7 -0
- data/lib/memorack/template/config.ru +5 -0
- data/lib/memorack/template/content/README.md +3 -0
- data/lib/memorack/template/themes/custom/config.json +15 -0
- data/lib/memorack/template/themes/custom/index.md +3 -0
- data/lib/memorack/themes/basic/2-column.scss +60 -0
- data/lib/memorack/themes/basic/basic-styles.scss +82 -0
- data/lib/memorack/themes/basic/config.json +14 -0
- data/lib/memorack/themes/basic/index.html +45 -0
- data/lib/memorack/themes/basic/styles.scss +9 -0
- data/lib/memorack/themes/oreilly/config.json +3 -0
- data/lib/memorack/themes/oreilly/oreilly/base.scss +33 -0
- data/lib/memorack/themes/oreilly/oreilly/styles.scss +138 -0
- data/lib/memorack/themes/oreilly/styles.scss +13 -0
- data/lib/memorack/tilt-mustache.rb +29 -0
- data/lib/memorack/version.rb +6 -0
- data/lib/memorack.rb +6 -0
- data/memorack.gemspec +45 -0
- data/spec/memorack_spec.rb +239 -0
- data/spec/spec_helper.rb +9 -0
- metadata +230 -0
@@ -0,0 +1,138 @@
|
|
1
|
+
@import "base";
|
2
|
+
|
3
|
+
|
4
|
+
$color: #00cc99;
|
5
|
+
|
6
|
+
|
7
|
+
/* mixin */
|
8
|
+
|
9
|
+
@mixin theme-color($color) {
|
10
|
+
header {
|
11
|
+
border-top: 12px solid $color;
|
12
|
+
}
|
13
|
+
|
14
|
+
.title {
|
15
|
+
background: $color;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
|
20
|
+
/* GitHub Badge */
|
21
|
+
|
22
|
+
#github {
|
23
|
+
right: -24px;
|
24
|
+
top: 32px;
|
25
|
+
position: absolute;
|
26
|
+
text-decoration: none;
|
27
|
+
text-align: right;
|
28
|
+
width: 320px;
|
29
|
+
@include transform(translate(60px, 42px) rotate(45deg));
|
30
|
+
span {
|
31
|
+
background: black;
|
32
|
+
color: white;
|
33
|
+
font-size: 14px;
|
34
|
+
left: 0;
|
35
|
+
padding: 5px 0;
|
36
|
+
position: absolute;
|
37
|
+
text-align: center;
|
38
|
+
width: 100%;
|
39
|
+
font-family: Arial,Verdana,'Bitstream Vera Sans',Helvetica,sans-serif;
|
40
|
+
font-weight: bold;
|
41
|
+
@include box-shadow(rgba(black, 0.2) 1px 1px 10px);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
/* O'reilly Like Style */
|
47
|
+
|
48
|
+
#page {
|
49
|
+
width: 800px;
|
50
|
+
margin: auto;
|
51
|
+
|
52
|
+
border: 1px solid #888;
|
53
|
+
padding: 0 36px 0;
|
54
|
+
position: relative;
|
55
|
+
|
56
|
+
@include box-shadow(2px 2px 6px rgba(100, 100, 100, .6));
|
57
|
+
}
|
58
|
+
|
59
|
+
header {
|
60
|
+
border-top: 12px solid $color;
|
61
|
+
padding: 0;
|
62
|
+
}
|
63
|
+
|
64
|
+
header a:link {
|
65
|
+
text-decoration: none;
|
66
|
+
}
|
67
|
+
|
68
|
+
.top-page header {
|
69
|
+
text-align: center;
|
70
|
+
}
|
71
|
+
|
72
|
+
footer {
|
73
|
+
text-align: center;
|
74
|
+
padding: 0 0 8px;
|
75
|
+
}
|
76
|
+
|
77
|
+
#lang {
|
78
|
+
font-size: 11px;
|
79
|
+
font-weight: bold;
|
80
|
+
}
|
81
|
+
|
82
|
+
#lang a:link,
|
83
|
+
#lang a:visited {
|
84
|
+
text-decoration: none;
|
85
|
+
color: #444;
|
86
|
+
}
|
87
|
+
|
88
|
+
.tagline {
|
89
|
+
color: black;
|
90
|
+
font-family: garamond, times new roman, times, serif;
|
91
|
+
font-style: italic;
|
92
|
+
font-weight: normal;
|
93
|
+
font-size: 21px;
|
94
|
+
padding: 0 0 20px 0;
|
95
|
+
margin: 8px 0 0;
|
96
|
+
text-align: center;
|
97
|
+
}
|
98
|
+
|
99
|
+
.subtitle {
|
100
|
+
color: black;
|
101
|
+
font-family: garamond, times new roman, times, serif;
|
102
|
+
font-style: italic;
|
103
|
+
font-weight: normal;
|
104
|
+
font-size: 28px;
|
105
|
+
padding: 0;
|
106
|
+
margin: 0 0 4px;
|
107
|
+
text-align: left;
|
108
|
+
}
|
109
|
+
|
110
|
+
.title {
|
111
|
+
background: $color;
|
112
|
+
color: white;
|
113
|
+
font-family: garamond, times new roman, times, serif;
|
114
|
+
font-weight: normal;
|
115
|
+
font-size: 84px;
|
116
|
+
text-align: center;
|
117
|
+
margin: 0 0 30px 0;
|
118
|
+
line-height: 100%;
|
119
|
+
}
|
120
|
+
|
121
|
+
.logo {
|
122
|
+
margin: 12px;
|
123
|
+
}
|
124
|
+
|
125
|
+
.content {
|
126
|
+
margin: 24px 30px 24px;
|
127
|
+
}
|
128
|
+
|
129
|
+
#author {
|
130
|
+
color: black;
|
131
|
+
font-family: garamond, times new roman, times, serif;
|
132
|
+
font-style: italic;
|
133
|
+
font-weight: normal;
|
134
|
+
font-size: 18px;
|
135
|
+
padding: 0;
|
136
|
+
margin: 0;
|
137
|
+
text-align: right;
|
138
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'tilt'
|
4
|
+
require 'tilt/template'
|
5
|
+
|
6
|
+
|
7
|
+
module Tilt
|
8
|
+
class MustacheTemplate < Template
|
9
|
+
def self.engine_initialized?
|
10
|
+
defined? ::Mustache
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize_engine
|
14
|
+
require_template_library 'mustache'
|
15
|
+
end
|
16
|
+
|
17
|
+
def prepare
|
18
|
+
@engine = Mustache.new
|
19
|
+
@engine.template = data
|
20
|
+
@output = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def evaluate(scope, locals, &block)
|
24
|
+
@output ||= @engine.render(locals)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
register MustacheTemplate, 'mustache'
|
29
|
+
end
|
data/lib/memorack.rb
ADDED
data/memorack.gemspec
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'memorack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "memorack"
|
8
|
+
gem.version = MemoRack::VERSION
|
9
|
+
gem.authors = ["gnue"]
|
10
|
+
gem.email = ["gnue@so-kukan.com"]
|
11
|
+
gem.description = %q{Rack Application for markdown memo}
|
12
|
+
gem.summary = %q{Rack Application for markdown memo}
|
13
|
+
gem.homepage = MemoRack::HOMEPAGE
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/) + %w(VERSION)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.required_ruby_version = '>= 1.9.0'
|
21
|
+
|
22
|
+
# dependency
|
23
|
+
gem.add_dependency('rack')
|
24
|
+
gem.add_dependency('tilt')
|
25
|
+
gem.add_dependency('mustache')
|
26
|
+
gem.add_dependency('redcarpet', '>= 2.0.0')
|
27
|
+
gem.add_dependency('json')
|
28
|
+
gem.add_dependency('sass')
|
29
|
+
gem.add_dependency('i18n')
|
30
|
+
|
31
|
+
# for development
|
32
|
+
gem.add_development_dependency('minitest')
|
33
|
+
gem.add_development_dependency('turn')
|
34
|
+
|
35
|
+
gem.post_install_message = %Q{
|
36
|
+
==================
|
37
|
+
Quick Start
|
38
|
+
|
39
|
+
$ memorack create memo
|
40
|
+
$ cd memo
|
41
|
+
$ rackup
|
42
|
+
|
43
|
+
==================
|
44
|
+
}
|
45
|
+
end
|
@@ -0,0 +1,239 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('../spec_helper', __FILE__)
|
4
|
+
require 'memorack'
|
5
|
+
require 'memorack/cli'
|
6
|
+
|
7
|
+
|
8
|
+
describe MemoRack do
|
9
|
+
class String
|
10
|
+
# 1行目のインデントだけ全体のインデントを削除する
|
11
|
+
def cut_indent(prefix = '')
|
12
|
+
prefix = Regexp.escape(prefix)
|
13
|
+
|
14
|
+
if self =~ /^(\s+#{prefix})/
|
15
|
+
indent = Regexp.escape($1)
|
16
|
+
self.gsub(/^#{indent}/,'')
|
17
|
+
else
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# MemoRack::CLI.run を呼出す
|
24
|
+
def memorack(*argv)
|
25
|
+
program_name = $0
|
26
|
+
|
27
|
+
begin
|
28
|
+
$0 = 'memorack'
|
29
|
+
MemoRack::CLI.run(argv)
|
30
|
+
rescue SystemExit => err
|
31
|
+
@abort = err.inspect
|
32
|
+
ensure
|
33
|
+
$0 = program_name
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# テンプレートを作成して cd する
|
38
|
+
def chmemo(name = 'memo')
|
39
|
+
Dir.chdir(@tmpdir) {
|
40
|
+
proc { memorack 'create', name }.must_output "Created '#{name}'\n"
|
41
|
+
|
42
|
+
Dir.chdir(name) {
|
43
|
+
yield(name)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
before do
|
49
|
+
require 'tmpdir'
|
50
|
+
@tmpdir = Dir.mktmpdir
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "usage" do
|
54
|
+
describe "en" do
|
55
|
+
before do
|
56
|
+
ENV['LANG'] = 'en_US.UTF-8'
|
57
|
+
end
|
58
|
+
|
59
|
+
it "usage" do
|
60
|
+
proc { memorack '-h' }.must_output nil, <<-EOD.cut_indent
|
61
|
+
Usage: memorack create [options] PATH
|
62
|
+
memorack theme [options] [THEME]
|
63
|
+
memorack server [options] PATH
|
64
|
+
|
65
|
+
-h, --help Show this message
|
66
|
+
EOD
|
67
|
+
end
|
68
|
+
|
69
|
+
it "create" do
|
70
|
+
proc { memorack 'create', '-h' }.must_output nil, <<-EOD.cut_indent
|
71
|
+
Usage: memorack create [options] PATH
|
72
|
+
-h, --help Show this message
|
73
|
+
EOD
|
74
|
+
end
|
75
|
+
|
76
|
+
it "theme" do
|
77
|
+
proc { memorack 'theme', '-h' }.must_output nil, <<-EOD.cut_indent
|
78
|
+
Usage: memorack theme [options] [THEME]
|
79
|
+
|
80
|
+
-c, --copy Copy theme
|
81
|
+
-d, --dir DIR Theme directory (default: themes)
|
82
|
+
-h, --help Show this message
|
83
|
+
EOD
|
84
|
+
end
|
85
|
+
|
86
|
+
it "server" do
|
87
|
+
proc { memorack 'server', '-h' }.must_output nil, <<-EOD.cut_indent
|
88
|
+
Usage: memorack server [options] PATH
|
89
|
+
|
90
|
+
-p, --port PORT use PORT (default: 9292)
|
91
|
+
-t, --theme THEME use THEME (default: oreilly)
|
92
|
+
-h, --help Show this message
|
93
|
+
EOD
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe "ja" do
|
98
|
+
before do
|
99
|
+
ENV['LANG'] = 'ja_JP.UTF-8'
|
100
|
+
end
|
101
|
+
|
102
|
+
it "usage" do
|
103
|
+
proc { memorack '-h' }.must_output nil, <<-EOD.cut_indent
|
104
|
+
Usage: memorack create [options] PATH
|
105
|
+
memorack theme [options] [THEME]
|
106
|
+
memorack server [options] PATH
|
107
|
+
|
108
|
+
-h, --help このメッセージを表示
|
109
|
+
EOD
|
110
|
+
end
|
111
|
+
|
112
|
+
it "create" do
|
113
|
+
proc { memorack 'create', '-h' }.must_output nil, <<-EOD.cut_indent
|
114
|
+
Usage: memorack create [options] PATH
|
115
|
+
-h, --help このメッセージを表示
|
116
|
+
EOD
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
it "theme" do
|
121
|
+
proc { memorack 'theme', '-h' }.must_output nil, <<-EOD.cut_indent
|
122
|
+
Usage: memorack theme [options] [THEME]
|
123
|
+
|
124
|
+
-c, --copy テーマをコピーする
|
125
|
+
-d, --dir DIR テーマのディレクトリー(省略値: themes)
|
126
|
+
-h, --help このメッセージを表示
|
127
|
+
EOD
|
128
|
+
end
|
129
|
+
|
130
|
+
it "server" do
|
131
|
+
proc { memorack 'server', '-h' }.must_output nil, <<-EOD.cut_indent
|
132
|
+
Usage: memorack server [options] PATH
|
133
|
+
|
134
|
+
-p, --port PORT ポートを使う (省略値: 9292)
|
135
|
+
-t, --theme THEME テーマを使う (省略値: oreilly)
|
136
|
+
-h, --help このメッセージを表示
|
137
|
+
EOD
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "create" do
|
143
|
+
it "create" do
|
144
|
+
name = 'memo'
|
145
|
+
|
146
|
+
Dir.chdir(@tmpdir) {
|
147
|
+
proc { memorack 'create', name }.must_output "Created '#{name}'\n"
|
148
|
+
`cd #{name}; find . -print`.must_equal <<-EOD.cut_indent
|
149
|
+
.
|
150
|
+
./.gitignore
|
151
|
+
./.powenv
|
152
|
+
./config.ru
|
153
|
+
./content
|
154
|
+
./content/README.md
|
155
|
+
./Gemfile
|
156
|
+
./themes
|
157
|
+
./themes/custom
|
158
|
+
./themes/custom/config.json
|
159
|
+
./themes/custom/index.md
|
160
|
+
EOD
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
it "create(File exists)" do
|
165
|
+
name = 'memo'
|
166
|
+
|
167
|
+
Dir.chdir(@tmpdir) {
|
168
|
+
Dir.mkdir name
|
169
|
+
proc { memorack 'create', name }.must_output nil, "File exists '#{name}'\n"
|
170
|
+
}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
describe "theme" do
|
175
|
+
it "theme" do
|
176
|
+
proc { memorack 'theme' }.must_output <<-EOD.cut_indent
|
177
|
+
MemoRack:
|
178
|
+
basic
|
179
|
+
oreilly
|
180
|
+
EOD
|
181
|
+
end
|
182
|
+
|
183
|
+
it "theme(with user)" do
|
184
|
+
chmemo { |name|
|
185
|
+
proc { memorack 'theme' }.must_output <<-EOD.cut_indent
|
186
|
+
MemoRack:
|
187
|
+
basic
|
188
|
+
oreilly
|
189
|
+
User:
|
190
|
+
custom
|
191
|
+
EOD
|
192
|
+
}
|
193
|
+
end
|
194
|
+
|
195
|
+
it "theme THEME" do
|
196
|
+
chmemo { |name|
|
197
|
+
proc { memorack 'theme', 'custom' }.must_output <<-EOD.cut_indent
|
198
|
+
custom --> [oreilly] --> [basic]
|
199
|
+
config.json
|
200
|
+
index.md
|
201
|
+
EOD
|
202
|
+
}
|
203
|
+
end
|
204
|
+
|
205
|
+
it "theme -c THEME" do
|
206
|
+
theme = 'basic'
|
207
|
+
|
208
|
+
chmemo { |name|
|
209
|
+
proc { memorack 'theme', '-c', theme }.must_output "Created 'themes/#{theme}'\n"
|
210
|
+
|
211
|
+
`cd themes/#{theme}; find . -print`.must_equal <<-EOD.cut_indent
|
212
|
+
.
|
213
|
+
./2-column.scss
|
214
|
+
./basic-styles.scss
|
215
|
+
./config.json
|
216
|
+
./index.html
|
217
|
+
./styles.scss
|
218
|
+
EOD
|
219
|
+
}
|
220
|
+
end
|
221
|
+
|
222
|
+
it "theme -c THEME/index.html" do
|
223
|
+
theme = 'basic'
|
224
|
+
fname = 'index.html'
|
225
|
+
|
226
|
+
chmemo { |name|
|
227
|
+
proc { memorack 'theme', '-c', File.join(theme, fname) }.must_output "Created '#{fname}'\n"
|
228
|
+
}
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
describe "server" do
|
233
|
+
it "server"
|
234
|
+
end
|
235
|
+
|
236
|
+
after do
|
237
|
+
FileUtils.remove_entry_secure @tmpdir
|
238
|
+
end
|
239
|
+
end
|