ruhoh 1.1 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -3
- data/README.md +3 -2
- data/Rakefile +1 -22
- data/bin/ruhoh +1 -5
- data/history.json +16 -0
- data/lib/ruhoh.rb +229 -84
- data/lib/ruhoh/base/collection.rb +280 -0
- data/lib/ruhoh/base/compiler.rb +55 -0
- data/lib/ruhoh/base/model.rb +220 -0
- data/lib/ruhoh/base/model_view.rb +152 -0
- data/lib/ruhoh/base/watcher.rb +25 -0
- data/lib/ruhoh/cache.rb +46 -0
- data/lib/ruhoh/client.rb +162 -0
- data/lib/ruhoh/collections.rb +172 -0
- data/lib/ruhoh/console_methods.rb +21 -0
- data/lib/ruhoh/{converters/converter.rb → converter.rb} +4 -1
- data/lib/ruhoh/programs/compile.rb +22 -0
- data/lib/ruhoh/programs/preview.rb +63 -0
- data/lib/ruhoh/programs/watch.rb +45 -0
- data/lib/ruhoh/resources/dash/collection.rb +10 -0
- data/lib/ruhoh/resources/dash/model.rb +5 -0
- data/lib/ruhoh/resources/dash/model_view.rb +5 -0
- data/lib/ruhoh/resources/dash/previewer.rb +13 -0
- data/lib/ruhoh/resources/data/collection.rb +9 -0
- data/lib/ruhoh/resources/data/collection_view.rb +23 -0
- data/lib/ruhoh/resources/javascripts/collection.rb +9 -0
- data/lib/ruhoh/resources/javascripts/collection_view.rb +46 -0
- data/lib/ruhoh/resources/javascripts/compiler.rb +5 -0
- data/lib/ruhoh/resources/layouts/client.rb +45 -0
- data/lib/ruhoh/resources/layouts/model.rb +16 -0
- data/lib/ruhoh/resources/media/collection.rb +9 -0
- data/lib/ruhoh/resources/media/compiler.rb +27 -0
- data/lib/ruhoh/resources/pages/client.rb +124 -0
- data/lib/ruhoh/resources/pages/collection.rb +86 -0
- data/lib/ruhoh/resources/pages/collection_view.rb +73 -0
- data/lib/ruhoh/resources/pages/compiler.rb +101 -0
- data/lib/ruhoh/resources/pages/model.rb +5 -0
- data/lib/ruhoh/resources/pages/model_view.rb +5 -0
- data/lib/ruhoh/resources/pages/previewer.rb +72 -0
- data/lib/ruhoh/resources/partials/model.rb +11 -0
- data/lib/ruhoh/resources/stylesheets/collection.rb +9 -0
- data/lib/ruhoh/resources/stylesheets/collection_view.rb +45 -0
- data/lib/ruhoh/resources/stylesheets/compiler.rb +5 -0
- data/lib/ruhoh/resources/theme/collection.rb +14 -0
- data/lib/ruhoh/resources/theme/compiler.rb +54 -0
- data/lib/ruhoh/resources/widgets/collection.rb +26 -0
- data/lib/ruhoh/resources/widgets/collection_view.rb +34 -0
- data/lib/ruhoh/resources/widgets/compiler.rb +27 -0
- data/lib/ruhoh/resources/widgets/model.rb +16 -0
- data/lib/ruhoh/routes.rb +29 -0
- data/lib/ruhoh/utils.rb +32 -49
- data/lib/ruhoh/version.rb +2 -2
- data/lib/ruhoh/views/helpers/categories.rb +38 -0
- data/lib/ruhoh/views/helpers/paginator.rb +39 -0
- data/lib/ruhoh/views/helpers/tags.rb +37 -0
- data/lib/ruhoh/views/master_view.rb +183 -0
- data/lib/ruhoh/views/rmustache.rb +24 -0
- data/ruhoh.gemspec +6 -82
- data/spec/spec_helper.rb +1 -1
- data/spec/support/shared_contexts.rb +6 -5
- data/system/{scaffolds/post.html → _scaffold.html} +1 -1
- data/system/{dash.html → dash/index.html} +37 -51
- data/system/{scaffolds/layout.html → layouts/_scaffold.html} +0 -0
- data/system/layouts/paginator.html +28 -0
- data/system/plugins/sprockets/javascripts/compiler.rb +25 -0
- data/system/plugins/sprockets/javascripts/previewer.rb +17 -0
- data/system/plugins/sprockets/stylesheets/compiler.rb +26 -0
- data/system/plugins/sprockets/stylesheets/previewer.rb +17 -0
- data/system/widgets/analytics/{layouts/getclicky.html → getclicky.html} +6 -2
- data/system/widgets/analytics/{layouts/google.html → google.html} +5 -1
- data/system/widgets/comments/{layouts/disqus.html → disqus.html} +6 -2
- data/system/widgets/comments/{layouts/facebook.html → facebook.html} +9 -2
- data/system/widgets/comments/{layouts/intensedebate.html → intensedebate.html} +5 -1
- data/system/widgets/comments/{layouts/livefyre.html → livefyre.html} +5 -1
- data/system/widgets/google_prettify/{layouts/google_prettify.html → default.html} +6 -2
- metadata +69 -66
- data/lib/ruhoh/client/client.rb +0 -306
- data/lib/ruhoh/client/console_methods.rb +0 -9
- data/lib/ruhoh/client/help.yml +0 -56
- data/lib/ruhoh/compiler.rb +0 -72
- data/lib/ruhoh/compilers/rss.rb +0 -39
- data/lib/ruhoh/compilers/theme.rb +0 -46
- data/lib/ruhoh/config.rb +0 -62
- data/lib/ruhoh/db.rb +0 -50
- data/lib/ruhoh/deployers/s3.rb +0 -71
- data/lib/ruhoh/page.rb +0 -106
- data/lib/ruhoh/parsers/javascripts.rb +0 -55
- data/lib/ruhoh/parsers/layouts.rb +0 -32
- data/lib/ruhoh/parsers/pages.rb +0 -79
- data/lib/ruhoh/parsers/partials.rb +0 -42
- data/lib/ruhoh/parsers/payload.rb +0 -49
- data/lib/ruhoh/parsers/posts.rb +0 -259
- data/lib/ruhoh/parsers/routes.rb +0 -20
- data/lib/ruhoh/parsers/scaffolds.rb +0 -35
- data/lib/ruhoh/parsers/site.rb +0 -19
- data/lib/ruhoh/parsers/stylesheets.rb +0 -63
- data/lib/ruhoh/parsers/theme_config.rb +0 -30
- data/lib/ruhoh/parsers/widgets.rb +0 -104
- data/lib/ruhoh/paths.rb +0 -83
- data/lib/ruhoh/previewer.rb +0 -48
- data/lib/ruhoh/program.rb +0 -68
- data/lib/ruhoh/templaters/asset_helpers.rb +0 -66
- data/lib/ruhoh/templaters/base_helpers.rb +0 -147
- data/lib/ruhoh/templaters/helpers.rb +0 -8
- data/lib/ruhoh/templaters/rmustache.rb +0 -70
- data/lib/ruhoh/urls.rb +0 -50
- data/lib/ruhoh/watch.rb +0 -78
- data/spec/config_spec.rb +0 -50
- data/spec/db_spec.rb +0 -91
- data/spec/page_spec.rb +0 -164
- data/spec/parsers/layouts_spec.rb +0 -41
- data/spec/parsers/pages_spec.rb +0 -120
- data/spec/parsers/posts_spec.rb +0 -309
- data/spec/parsers/routes_spec.rb +0 -39
- data/spec/parsers/site_spec.rb +0 -28
- data/spec/setup_spec.rb +0 -12
- data/system/scaffolds/draft.html +0 -9
- data/system/scaffolds/page.html +0 -4
- data/system/widgets/analytics/config.yml +0 -5
- data/system/widgets/comments/config.yml +0 -13
- data/system/widgets/google_prettify/config.yml +0 -1
@@ -1,9 +1,16 @@
|
|
1
|
+
---
|
2
|
+
appid : 123
|
3
|
+
num_posts: 5
|
4
|
+
width: 580
|
5
|
+
colorscheme: light
|
6
|
+
---
|
7
|
+
|
1
8
|
<div id="fb-root"></div>
|
2
9
|
<script>(function(d, s, id) {
|
3
10
|
var js, fjs = d.getElementsByTagName(s)[0];
|
4
11
|
if (d.getElementById(id)) return;
|
5
12
|
js = d.createElement(s); js.id = id;
|
6
|
-
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={{
|
13
|
+
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={{ this_config.appid }}";
|
7
14
|
fjs.parentNode.insertBefore(js, fjs);
|
8
15
|
}(document, 'script', 'facebook-jssdk'));</script>
|
9
|
-
<div class="fb-comments" data-href="{{
|
16
|
+
<div class="fb-comments" data-href="{{ urls.production_url }}" data-num-posts="{{ this_config.num_posts }}" data-width="{{ this_config.width }}" data-colorscheme="{{ this_config.colorscheme }}"></div>
|
@@ -1,6 +1,10 @@
|
|
1
|
+
---
|
2
|
+
site_id : 123
|
3
|
+
---
|
4
|
+
|
1
5
|
<script type='text/javascript' src='http://zor.livefyre.com/wjs/v1.0/javascripts/livefyre_init.js'></script>
|
2
6
|
<script type='text/javascript'>
|
3
7
|
var fyre = LF({
|
4
|
-
site_id: {{
|
8
|
+
site_id: {{ this_config.site_id }}
|
5
9
|
});
|
6
10
|
</script>
|
@@ -1,10 +1,14 @@
|
|
1
|
+
---
|
2
|
+
linenums : true
|
3
|
+
---
|
4
|
+
|
1
5
|
<!-- Google Prettify -->
|
2
6
|
<script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script>
|
3
7
|
<script>
|
4
8
|
var pres = document.getElementsByTagName("pre");
|
5
9
|
for (var i=0; i < pres.length; ++i) {
|
6
|
-
pres[i].className = "prettyprint {{#
|
10
|
+
pres[i].className = "prettyprint {{# this_config.linenums }}linenums{{/this_config.linenums}}";
|
7
11
|
}
|
8
12
|
prettyPrint();
|
9
13
|
</script>
|
10
|
-
<!-- end Google Prettify -->
|
14
|
+
<!-- end Google Prettify -->
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruhoh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '
|
4
|
+
version: '2.1'
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ~>
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 1.4.0
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.4.0
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: redcarpet
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,76 +104,84 @@ files:
|
|
104
104
|
- bin/ruhoh
|
105
105
|
- history.json
|
106
106
|
- lib/ruhoh.rb
|
107
|
-
- lib/ruhoh/
|
108
|
-
- lib/ruhoh/
|
109
|
-
- lib/ruhoh/
|
110
|
-
- lib/ruhoh/
|
111
|
-
- lib/ruhoh/
|
112
|
-
- lib/ruhoh/
|
113
|
-
- lib/ruhoh/
|
114
|
-
- lib/ruhoh/
|
107
|
+
- lib/ruhoh/base/collection.rb
|
108
|
+
- lib/ruhoh/base/compiler.rb
|
109
|
+
- lib/ruhoh/base/model.rb
|
110
|
+
- lib/ruhoh/base/model_view.rb
|
111
|
+
- lib/ruhoh/base/watcher.rb
|
112
|
+
- lib/ruhoh/cache.rb
|
113
|
+
- lib/ruhoh/client.rb
|
114
|
+
- lib/ruhoh/collections.rb
|
115
|
+
- lib/ruhoh/console_methods.rb
|
116
|
+
- lib/ruhoh/converter.rb
|
115
117
|
- lib/ruhoh/converters/markdown.rb
|
116
|
-
- lib/ruhoh/db.rb
|
117
|
-
- lib/ruhoh/deployers/s3.rb
|
118
118
|
- lib/ruhoh/friend.rb
|
119
119
|
- lib/ruhoh/logger.rb
|
120
|
-
- lib/ruhoh/
|
121
|
-
- lib/ruhoh/
|
122
|
-
- lib/ruhoh/
|
123
|
-
- lib/ruhoh/
|
124
|
-
- lib/ruhoh/
|
125
|
-
- lib/ruhoh/
|
126
|
-
- lib/ruhoh/
|
127
|
-
- lib/ruhoh/
|
128
|
-
- lib/ruhoh/
|
129
|
-
- lib/ruhoh/
|
130
|
-
- lib/ruhoh/
|
131
|
-
- lib/ruhoh/
|
132
|
-
- lib/ruhoh/
|
133
|
-
- lib/ruhoh/
|
134
|
-
- lib/ruhoh/
|
135
|
-
- lib/ruhoh/
|
136
|
-
- lib/ruhoh/
|
137
|
-
- lib/ruhoh/
|
138
|
-
- lib/ruhoh/
|
139
|
-
- lib/ruhoh/
|
140
|
-
- lib/ruhoh/
|
120
|
+
- lib/ruhoh/programs/compile.rb
|
121
|
+
- lib/ruhoh/programs/preview.rb
|
122
|
+
- lib/ruhoh/programs/watch.rb
|
123
|
+
- lib/ruhoh/resources/dash/collection.rb
|
124
|
+
- lib/ruhoh/resources/dash/model.rb
|
125
|
+
- lib/ruhoh/resources/dash/model_view.rb
|
126
|
+
- lib/ruhoh/resources/dash/previewer.rb
|
127
|
+
- lib/ruhoh/resources/data/collection.rb
|
128
|
+
- lib/ruhoh/resources/data/collection_view.rb
|
129
|
+
- lib/ruhoh/resources/javascripts/collection.rb
|
130
|
+
- lib/ruhoh/resources/javascripts/collection_view.rb
|
131
|
+
- lib/ruhoh/resources/javascripts/compiler.rb
|
132
|
+
- lib/ruhoh/resources/layouts/client.rb
|
133
|
+
- lib/ruhoh/resources/layouts/model.rb
|
134
|
+
- lib/ruhoh/resources/media/collection.rb
|
135
|
+
- lib/ruhoh/resources/media/compiler.rb
|
136
|
+
- lib/ruhoh/resources/pages/client.rb
|
137
|
+
- lib/ruhoh/resources/pages/collection.rb
|
138
|
+
- lib/ruhoh/resources/pages/collection_view.rb
|
139
|
+
- lib/ruhoh/resources/pages/compiler.rb
|
140
|
+
- lib/ruhoh/resources/pages/model.rb
|
141
|
+
- lib/ruhoh/resources/pages/model_view.rb
|
142
|
+
- lib/ruhoh/resources/pages/previewer.rb
|
143
|
+
- lib/ruhoh/resources/partials/model.rb
|
144
|
+
- lib/ruhoh/resources/stylesheets/collection.rb
|
145
|
+
- lib/ruhoh/resources/stylesheets/collection_view.rb
|
146
|
+
- lib/ruhoh/resources/stylesheets/compiler.rb
|
147
|
+
- lib/ruhoh/resources/theme/collection.rb
|
148
|
+
- lib/ruhoh/resources/theme/compiler.rb
|
149
|
+
- lib/ruhoh/resources/widgets/collection.rb
|
150
|
+
- lib/ruhoh/resources/widgets/collection_view.rb
|
151
|
+
- lib/ruhoh/resources/widgets/compiler.rb
|
152
|
+
- lib/ruhoh/resources/widgets/model.rb
|
153
|
+
- lib/ruhoh/routes.rb
|
141
154
|
- lib/ruhoh/utils.rb
|
142
155
|
- lib/ruhoh/version.rb
|
143
|
-
- lib/ruhoh/
|
156
|
+
- lib/ruhoh/views/helpers/categories.rb
|
157
|
+
- lib/ruhoh/views/helpers/paginator.rb
|
158
|
+
- lib/ruhoh/views/helpers/tags.rb
|
159
|
+
- lib/ruhoh/views/master_view.rb
|
160
|
+
- lib/ruhoh/views/rmustache.rb
|
144
161
|
- ruhoh.gemspec
|
145
|
-
- spec/config_spec.rb
|
146
|
-
- spec/db_spec.rb
|
147
|
-
- spec/page_spec.rb
|
148
|
-
- spec/parsers/layouts_spec.rb
|
149
|
-
- spec/parsers/pages_spec.rb
|
150
|
-
- spec/parsers/posts_spec.rb
|
151
|
-
- spec/parsers/routes_spec.rb
|
152
|
-
- spec/parsers/site_spec.rb
|
153
|
-
- spec/setup_spec.rb
|
154
162
|
- spec/spec_helper.rb
|
155
163
|
- spec/support/shared_contexts.rb
|
156
|
-
- system/
|
164
|
+
- system/_scaffold.html
|
165
|
+
- system/dash/index.html
|
166
|
+
- system/layouts/_scaffold.html
|
167
|
+
- system/layouts/paginator.html
|
157
168
|
- system/partials/categories_list.html
|
158
169
|
- system/partials/pages_list.html
|
159
170
|
- system/partials/posts_collate.html
|
160
171
|
- system/partials/posts_list.html
|
161
172
|
- system/partials/posts_summary.html
|
162
173
|
- system/partials/tags_list.html
|
163
|
-
- system/
|
164
|
-
- system/
|
165
|
-
- system/
|
166
|
-
- system/
|
167
|
-
- system/widgets/analytics/
|
168
|
-
- system/widgets/analytics/
|
169
|
-
- system/widgets/
|
170
|
-
- system/widgets/comments/
|
171
|
-
- system/widgets/comments/
|
172
|
-
- system/widgets/comments/
|
173
|
-
- system/widgets/
|
174
|
-
- system/widgets/comments/layouts/livefyre.html
|
175
|
-
- system/widgets/google_prettify/config.yml
|
176
|
-
- system/widgets/google_prettify/layouts/google_prettify.html
|
174
|
+
- system/plugins/sprockets/javascripts/compiler.rb
|
175
|
+
- system/plugins/sprockets/javascripts/previewer.rb
|
176
|
+
- system/plugins/sprockets/stylesheets/compiler.rb
|
177
|
+
- system/plugins/sprockets/stylesheets/previewer.rb
|
178
|
+
- system/widgets/analytics/getclicky.html
|
179
|
+
- system/widgets/analytics/google.html
|
180
|
+
- system/widgets/comments/disqus.html
|
181
|
+
- system/widgets/comments/facebook.html
|
182
|
+
- system/widgets/comments/intensedebate.html
|
183
|
+
- system/widgets/comments/livefyre.html
|
184
|
+
- system/widgets/google_prettify/default.html
|
177
185
|
homepage: http://github.com/ruhoh/ruhoh.rb
|
178
186
|
licenses:
|
179
187
|
- http://www.opensource.org/licenses/MIT
|
@@ -187,18 +195,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
187
195
|
- - ! '>='
|
188
196
|
- !ruby/object:Gem::Version
|
189
197
|
version: '0'
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
hash: -2404318061189800228
|
193
198
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
199
|
none: false
|
195
200
|
requirements:
|
196
201
|
- - ! '>='
|
197
202
|
- !ruby/object:Gem::Version
|
198
203
|
version: '0'
|
199
|
-
segments:
|
200
|
-
- 0
|
201
|
-
hash: -2404318061189800228
|
202
204
|
requirements: []
|
203
205
|
rubyforge_project:
|
204
206
|
rubygems_version: 1.8.24
|
@@ -206,3 +208,4 @@ signing_key:
|
|
206
208
|
specification_version: 3
|
207
209
|
summary: Ruby based library to process your Ruhoh static blog.
|
208
210
|
test_files: []
|
211
|
+
has_rdoc:
|
data/lib/ruhoh/client/client.rb
DELETED
@@ -1,306 +0,0 @@
|
|
1
|
-
require 'ruhoh/compiler'
|
2
|
-
require 'ruhoh/client/console_methods'
|
3
|
-
require 'irb'
|
4
|
-
|
5
|
-
class Ruhoh
|
6
|
-
|
7
|
-
class Client
|
8
|
-
|
9
|
-
Paths = Struct.new(:page_template, :draft_template, :post_template, :layout_template, :theme_template)
|
10
|
-
DefaultBlogScaffold = 'git://github.com/ruhoh/blog.git'
|
11
|
-
|
12
|
-
def initialize(data)
|
13
|
-
@iterator = 0
|
14
|
-
self.setup_options(data)
|
15
|
-
|
16
|
-
cmd = (data[:args][0] == 'new') ? 'blog' : (data[:args][0] || 'help')
|
17
|
-
Ruhoh::Friend.say {
|
18
|
-
red "Command not found"
|
19
|
-
exit
|
20
|
-
} unless self.respond_to?(cmd)
|
21
|
-
|
22
|
-
unless ['help','blog','compile'].include?(cmd)
|
23
|
-
Ruhoh.setup
|
24
|
-
Ruhoh.setup_paths
|
25
|
-
Ruhoh.setup_urls
|
26
|
-
end
|
27
|
-
|
28
|
-
self.__send__(cmd)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Thanks rails! https://github.com/rails/rails/blob/master/railties/lib/rails/commands/console.rb
|
32
|
-
def console
|
33
|
-
ARGV.clear # IRB throws an error otherwise.
|
34
|
-
require 'pp'
|
35
|
-
IRB::ExtendCommandBundle.send :include, Ruhoh::ConsoleMethods
|
36
|
-
IRB.start
|
37
|
-
end
|
38
|
-
|
39
|
-
def setup_options(data)
|
40
|
-
@args = data[:args]
|
41
|
-
@options = data[:options]
|
42
|
-
@opt_parser = data[:opt_parser]
|
43
|
-
@options.ext = (@options.ext || 'md').gsub('.', '')
|
44
|
-
end
|
45
|
-
|
46
|
-
# Internal: Show Client Utility help documentation.
|
47
|
-
def help
|
48
|
-
file = File.join(Ruhoh::Root, 'lib', 'ruhoh', 'client', 'help.yml')
|
49
|
-
content = Ruhoh::Utils.parse_yaml_file(file)
|
50
|
-
options = @opt_parser.help
|
51
|
-
Ruhoh::Friend.say {
|
52
|
-
plain content['description']
|
53
|
-
plain ''
|
54
|
-
plain options
|
55
|
-
plain ''
|
56
|
-
plain 'Commands:'
|
57
|
-
plain ''
|
58
|
-
content['commands'].each do |a|
|
59
|
-
green(" " + a["command"])
|
60
|
-
plain(" "+ a["desc"])
|
61
|
-
end
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
def draft
|
66
|
-
self.draft_or_post(:draft)
|
67
|
-
end
|
68
|
-
|
69
|
-
def post
|
70
|
-
self.draft_or_post(:post)
|
71
|
-
end
|
72
|
-
|
73
|
-
def draft_or_post(type)
|
74
|
-
begin
|
75
|
-
name = @args[1] || "untitled-#{type}"
|
76
|
-
name = "#{name}-#{@iterator}" unless @iterator.zero?
|
77
|
-
name = Ruhoh::Urls.to_slug(name)
|
78
|
-
filename = File.join(Ruhoh.paths.posts, "#{name}.#{@options.ext}")
|
79
|
-
@iterator += 1
|
80
|
-
end while File.exist?(filename)
|
81
|
-
|
82
|
-
Ruhoh::DB.update(:scaffolds)
|
83
|
-
|
84
|
-
FileUtils.mkdir_p File.dirname(filename)
|
85
|
-
output = Ruhoh::DB.scaffolds["#{type}.html"].to_s
|
86
|
-
output = output.gsub('{{DATE}}', Ruhoh::Parsers::Posts.formatted_date(Time.now))
|
87
|
-
File.open(filename, 'w:UTF-8') {|f| f.puts output }
|
88
|
-
|
89
|
-
Ruhoh::Friend.say {
|
90
|
-
green "New #{type}:"
|
91
|
-
green Ruhoh::Utils.relative_path(filename)
|
92
|
-
green 'View drafts at the URL: /dash'
|
93
|
-
}
|
94
|
-
end
|
95
|
-
|
96
|
-
# Public: Create a new page file.
|
97
|
-
def page
|
98
|
-
name = @args[1]
|
99
|
-
Ruhoh::Friend.say {
|
100
|
-
red "Please specify a path"
|
101
|
-
plain " ex: ruhoh page projects/hello-world"
|
102
|
-
exit
|
103
|
-
} if (name.nil? || name.gsub(/\s/, '').empty?)
|
104
|
-
|
105
|
-
filename = File.join(Ruhoh.paths.pages, name.gsub(/\s/, '-'))
|
106
|
-
filename = File.join(filename, "index.#{@options.ext}") if File.extname(filename) == ""
|
107
|
-
if File.exist?(filename)
|
108
|
-
abort("Create new page: aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
|
109
|
-
end
|
110
|
-
|
111
|
-
Ruhoh::DB.update(:scaffolds)
|
112
|
-
|
113
|
-
FileUtils.mkdir_p File.dirname(filename)
|
114
|
-
File.open(filename, 'w:UTF-8') do |page|
|
115
|
-
page.puts Ruhoh::DB.scaffolds['page.html'].to_s
|
116
|
-
end
|
117
|
-
|
118
|
-
Ruhoh::Friend.say {
|
119
|
-
green "New page:"
|
120
|
-
plain Ruhoh::Utils.relative_path(filename)
|
121
|
-
}
|
122
|
-
end
|
123
|
-
|
124
|
-
# Public: Update draft filenames to their corresponding titles.
|
125
|
-
def titleize
|
126
|
-
Ruhoh::Parsers::Posts.files.each do |file|
|
127
|
-
next unless File.basename(file) =~ /^untitled/
|
128
|
-
parsed_page = Ruhoh::Utils.parse_page_file(file)
|
129
|
-
next unless parsed_page['data']['title']
|
130
|
-
new_name = Ruhoh::Urls.to_slug(parsed_page['data']['title'])
|
131
|
-
new_file = File.join(File.dirname(file), "#{new_name}#{File.extname(file)}")
|
132
|
-
FileUtils.mv(file, new_file)
|
133
|
-
Ruhoh::Friend.say { green "Renamed #{file} to: #{new_file}" }
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
# Public: Compile to static website.
|
138
|
-
def compile
|
139
|
-
Ruhoh::Program.compile(@args[1])
|
140
|
-
end
|
141
|
-
|
142
|
-
# Public: Create a new blog at the directory provided.
|
143
|
-
def blog
|
144
|
-
name = @args[1]
|
145
|
-
scaffold = @args.length > 2 ? @args[2] : DefaultBlogScaffold
|
146
|
-
useHg = @options.hg
|
147
|
-
Ruhoh::Friend.say {
|
148
|
-
red "Please specify a directory path."
|
149
|
-
plain " ex: ruhoh new the-blogist"
|
150
|
-
exit
|
151
|
-
} if name.nil?
|
152
|
-
|
153
|
-
target_directory = File.join(Dir.pwd, name)
|
154
|
-
|
155
|
-
Ruhoh::Friend.say {
|
156
|
-
red "#{target_directory} already exists."
|
157
|
-
plain " Specify another directory or `rm -rf` this directory first."
|
158
|
-
exit
|
159
|
-
} if File.exist?(target_directory)
|
160
|
-
|
161
|
-
Ruhoh::Friend.say {
|
162
|
-
plain "Trying this command:"
|
163
|
-
|
164
|
-
if useHg
|
165
|
-
cyan " hg clone #{scaffold} #{target_directory}"
|
166
|
-
success = system('hg', 'clone', scaffold, target_directory)
|
167
|
-
else
|
168
|
-
cyan " git clone #{scaffold} #{target_directory}"
|
169
|
-
success = system('git', 'clone', scaffold, target_directory)
|
170
|
-
end
|
171
|
-
|
172
|
-
if success
|
173
|
-
green "Success! Now do..."
|
174
|
-
cyan " cd #{target_directory}"
|
175
|
-
cyan " rackup -p9292"
|
176
|
-
cyan " http://localhost:9292"
|
177
|
-
else
|
178
|
-
red "Could not git clone blog scaffold. Please try it manually:"
|
179
|
-
cyan " git clone git://github.com/ruhoh/blog.git #{target_directory}"
|
180
|
-
end
|
181
|
-
}
|
182
|
-
end
|
183
|
-
|
184
|
-
# Public: Create a new layout file for the active theme.
|
185
|
-
def layout
|
186
|
-
name = @args[1]
|
187
|
-
Ruhoh::Friend.say {
|
188
|
-
red "Please specify a layout name."
|
189
|
-
cyan "ex: ruhoh new layout splash"
|
190
|
-
exit
|
191
|
-
} if name.nil?
|
192
|
-
|
193
|
-
filename = File.join(Ruhoh.paths.theme_layouts, name.gsub(/\s/, '-').downcase) + ".html"
|
194
|
-
if File.exist?(filename)
|
195
|
-
abort("Create new layout: aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
|
196
|
-
end
|
197
|
-
|
198
|
-
Ruhoh::DB.update(:scaffolds)
|
199
|
-
|
200
|
-
FileUtils.mkdir_p File.dirname(filename)
|
201
|
-
File.open(filename, 'w:UTF-8') do |page|
|
202
|
-
page.puts Ruhoh::DB.scaffolds['layout.html'].to_s
|
203
|
-
end
|
204
|
-
|
205
|
-
Ruhoh::Friend.say {
|
206
|
-
green "New layout:"
|
207
|
-
plain Ruhoh::Utils.relative_path(filename)
|
208
|
-
}
|
209
|
-
end
|
210
|
-
|
211
|
-
# Public : List drafts
|
212
|
-
def drafts
|
213
|
-
self.list(:drafts)
|
214
|
-
end
|
215
|
-
|
216
|
-
# Public : List posts
|
217
|
-
def posts
|
218
|
-
self.list(:posts)
|
219
|
-
end
|
220
|
-
|
221
|
-
# Public : List pages
|
222
|
-
def pages
|
223
|
-
self.list(:pages)
|
224
|
-
end
|
225
|
-
|
226
|
-
# Return the payload hash for inspection/study.
|
227
|
-
def payload
|
228
|
-
require 'pp'
|
229
|
-
Ruhoh::DB.update_all
|
230
|
-
Ruhoh::Friend.say {
|
231
|
-
plain Ruhoh::DB.payload.pretty_inspect
|
232
|
-
}
|
233
|
-
end
|
234
|
-
|
235
|
-
# Internal: Outputs a list of the given data-type to the terminal.
|
236
|
-
def list(type)
|
237
|
-
data = case type
|
238
|
-
when :posts
|
239
|
-
Ruhoh::DB.update(:posts)
|
240
|
-
Ruhoh::DB.posts['dictionary']
|
241
|
-
when :drafts
|
242
|
-
Ruhoh::DB.update(:posts)
|
243
|
-
drafts = Ruhoh::DB.posts['drafts']
|
244
|
-
h = {}
|
245
|
-
drafts.each {|id| h[id] = Ruhoh::DB.posts['dictionary'][id]}
|
246
|
-
h
|
247
|
-
when :pages
|
248
|
-
Ruhoh::DB.update(:pages)
|
249
|
-
Ruhoh::DB.pages
|
250
|
-
end
|
251
|
-
|
252
|
-
if @options.verbose
|
253
|
-
Ruhoh::Friend.say {
|
254
|
-
data.each_value do |p|
|
255
|
-
cyan("- #{p['id']}")
|
256
|
-
plain(" title: #{p['title']}")
|
257
|
-
plain(" url: #{p['url']}")
|
258
|
-
end
|
259
|
-
}
|
260
|
-
else
|
261
|
-
Ruhoh::Friend.say {
|
262
|
-
data.each_value do |p|
|
263
|
-
cyan("- #{p['id']}")
|
264
|
-
end
|
265
|
-
}
|
266
|
-
end
|
267
|
-
end
|
268
|
-
|
269
|
-
# Internal: Get the last active file based on data-type.
|
270
|
-
# Note File.ctime is the last time the file was changed as opposed to created.
|
271
|
-
# Returns: String file id, where id is the relative path to the file.
|
272
|
-
def last(type)
|
273
|
-
self.get_files(type).sort_by { |f| File.ctime(f) }.last || nil
|
274
|
-
end
|
275
|
-
|
276
|
-
# Internal: Get an Array list of file ids based on the data-type.
|
277
|
-
# Returns: Array of file ids (ids are relative paths to the file.)
|
278
|
-
def get_files(type)
|
279
|
-
case type
|
280
|
-
when 'post'
|
281
|
-
Ruhoh::Parsers::Posts.files
|
282
|
-
when 'page'
|
283
|
-
Ruhoh::Parsers::Pages.files
|
284
|
-
else
|
285
|
-
Ruhoh::Friend.say { red "Type: '#{type}' not supported." }
|
286
|
-
exit
|
287
|
-
end
|
288
|
-
end
|
289
|
-
|
290
|
-
def ask(message, valid_options)
|
291
|
-
if valid_options
|
292
|
-
answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /,'/')} ") while !valid_options.include?(answer)
|
293
|
-
else
|
294
|
-
answer = get_stdin(message)
|
295
|
-
end
|
296
|
-
answer
|
297
|
-
end
|
298
|
-
|
299
|
-
def get_stdin(message)
|
300
|
-
print message
|
301
|
-
STDIN.gets.chomp
|
302
|
-
end
|
303
|
-
|
304
|
-
|
305
|
-
end #Client
|
306
|
-
end #Ruhoh
|