ruhoh 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (87) hide show
  1. data/Gemfile +13 -0
  2. data/README.md +5 -53
  3. data/Rakefile +56 -0
  4. data/bin/ruhoh +23 -14
  5. data/lib/ruhoh/client/client.rb +310 -0
  6. data/lib/ruhoh/client/help.yml +56 -0
  7. data/lib/ruhoh/compiler.rb +16 -19
  8. data/lib/ruhoh/converters/converter.rb +30 -3
  9. data/lib/ruhoh/db.rb +7 -17
  10. data/lib/ruhoh/deployers/s3.rb +71 -0
  11. data/lib/ruhoh/friend.rb +71 -0
  12. data/lib/ruhoh/page.rb +41 -11
  13. data/lib/ruhoh/parsers/drafts.rb +54 -0
  14. data/lib/ruhoh/parsers/layouts.rb +14 -9
  15. data/lib/ruhoh/parsers/pages.rb +47 -35
  16. data/lib/ruhoh/parsers/partials.rb +14 -2
  17. data/lib/ruhoh/parsers/posts.rb +139 -88
  18. data/lib/ruhoh/parsers/routes.rb +4 -8
  19. data/lib/ruhoh/parsers/site.rb +2 -8
  20. data/lib/ruhoh/previewer.rb +48 -0
  21. data/lib/ruhoh/templaters/base.rb +53 -0
  22. data/lib/ruhoh/templaters/helpers.rb +159 -0
  23. data/lib/ruhoh/templaters/rmustache.rb +29 -0
  24. data/lib/ruhoh/utils.rb +25 -7
  25. data/lib/ruhoh/version.rb +1 -1
  26. data/lib/ruhoh/watch.rb +22 -9
  27. data/lib/ruhoh.rb +74 -29
  28. data/ruhoh.gemspec +70 -9
  29. data/scaffolds/blog/_config.yml +33 -0
  30. data/scaffolds/blog/_drafts/.gitkeep +0 -0
  31. data/scaffolds/blog/_posts/.gitkeep +0 -0
  32. data/scaffolds/blog/_site.yml +16 -0
  33. data/scaffolds/blog/_templates/partials/categories_list +3 -0
  34. data/scaffolds/blog/_templates/partials/pages_list +7 -0
  35. data/scaffolds/blog/_templates/partials/posts_collate +9 -0
  36. data/scaffolds/blog/_templates/partials/posts_list +1 -0
  37. data/scaffolds/blog/_templates/partials/tags_list +3 -0
  38. data/scaffolds/blog/_templates/syntax/google_prettify/default.css +52 -0
  39. data/scaffolds/blog/_templates/syntax/google_prettify/desert.css +34 -0
  40. data/scaffolds/blog/_templates/syntax/google_prettify/sons-of-obsidian.css +117 -0
  41. data/scaffolds/blog/_templates/syntax/google_prettify/sunburst.css +51 -0
  42. data/scaffolds/blog/_templates/syntax/google_prettify/twitter-bootstrap.css +30 -0
  43. data/scaffolds/blog/_templates/themes/twitter/bootstrap/css/bootstrap.min.css +689 -0
  44. data/scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings-white.png +0 -0
  45. data/scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings.png +0 -0
  46. data/scaffolds/blog/_templates/themes/twitter/css/style.css +68 -0
  47. data/scaffolds/blog/_templates/themes/twitter/layouts/default.html +64 -0
  48. data/scaffolds/blog/_templates/themes/twitter/layouts/page.html +13 -0
  49. data/scaffolds/blog/_templates/themes/twitter/layouts/post.html +55 -0
  50. data/scaffolds/blog/_templates/themes/twitter/manifest.yml +11 -0
  51. data/scaffolds/blog/about.md +5 -0
  52. data/scaffolds/blog/archive.html +11 -0
  53. data/scaffolds/blog/categories.html +21 -0
  54. data/scaffolds/blog/config.ru +9 -0
  55. data/scaffolds/blog/index.html +13 -0
  56. data/scaffolds/blog/pages.html +14 -0
  57. data/scaffolds/blog/tags.html +21 -0
  58. data/scaffolds/layout.html +3 -0
  59. data/scaffolds/page.html +6 -0
  60. data/scaffolds/post.html +8 -0
  61. data/scaffolds/theme/css/style.css +0 -0
  62. data/scaffolds/theme/images/.gitkeep +0 -0
  63. data/scaffolds/theme/layouts/default.html +17 -0
  64. data/scaffolds/theme/layouts/page.html +7 -0
  65. data/scaffolds/theme/layouts/post.html +8 -0
  66. data/scaffolds/theme/partials/.gitkeep +0 -0
  67. data/spec/db_spec.rb +88 -0
  68. data/spec/page_spec.rb +200 -0
  69. data/spec/parsers/layouts_spec.rb +32 -0
  70. data/spec/parsers/pages_spec.rb +97 -0
  71. data/spec/parsers/posts_spec.rb +301 -0
  72. data/spec/parsers/routes_spec.rb +45 -0
  73. data/spec/parsers/site_spec.rb +32 -0
  74. data/spec/setup_spec.rb +72 -0
  75. data/spec/spec_helper.rb +23 -0
  76. data/system_partials/analytics/getclicky +12 -0
  77. data/system_partials/analytics/google +11 -0
  78. data/system_partials/comments/disqus +13 -0
  79. data/system_partials/comments/facebook +9 -0
  80. data/system_partials/comments/intensedebate +6 -0
  81. data/system_partials/comments/livefyre +6 -0
  82. data/system_partials/syntax/google_prettify +11 -0
  83. metadata +84 -23
  84. data/lib/ruhoh/client.rb +0 -28
  85. data/lib/ruhoh/preview.rb +0 -36
  86. data/lib/ruhoh/templaters/helper_mustache.rb +0 -109
  87. data/lib/ruhoh/templaters/templater.rb +0 -39
@@ -0,0 +1,11 @@
1
+ <!-- Google Prettify -->
2
+ <link rel="stylesheet" href="{{ SYNTAX_PATH }}/google_prettify/{{ site.config.syntax.google_prettify.theme }}.css" type="text/css" media="screen" charset="utf-8">
3
+ <script src="http://cdnjs.cloudflare.com/ajax/libs/prettify/188.0.0/prettify.js"></script>
4
+ <script>
5
+ var pres = document.getElementsByTagName("pre");
6
+ for (var i=0; i < pres.length; ++i) {
7
+ pres[i].className = "prettyprint {{# site.config.syntax.google_prettify.linenums }}linenums{{/site.config.syntax.google_prettify.linenums}}";
8
+ }
9
+ prettyPrint();
10
+ </script>
11
+ <!-- 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: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,52 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-07 00:00:00.000000000Z
12
+ date: 2012-03-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70125560161900 !ruby/object:Gem::Requirement
16
+ requirement: &70238314583000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70125560161900
24
+ version_requirements: *70238314583000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: mustache
27
- requirement: &70125560161480 !ruby/object:Gem::Requirement
27
+ requirement: &70238314582500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: '0.99'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70125560161480
35
+ version_requirements: *70238314582500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: directory_watcher
38
- requirement: &70125560190740 !ruby/object:Gem::Requirement
38
+ requirement: &70238314582040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>='
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: '1.4'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70125560190740
46
+ version_requirements: *70238314582040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: maruku
49
- requirement: &70125560190320 !ruby/object:Gem::Requirement
49
+ requirement: &70238314581580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '0.6'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70125560190320
57
+ version_requirements: *70238314581580
58
58
  description: Ruhoh is a Universal API for your static blog.
59
59
  email: plusjade@gmail.com
60
60
  executables:
@@ -62,28 +62,89 @@ executables:
62
62
  extensions: []
63
63
  extra_rdoc_files: []
64
64
  files:
65
+ - Gemfile
65
66
  - README.md
67
+ - Rakefile
66
68
  - bin/ruhoh
67
69
  - lib/ruhoh.rb
68
- - lib/ruhoh/client.rb
70
+ - lib/ruhoh/client/client.rb
71
+ - lib/ruhoh/client/help.yml
69
72
  - lib/ruhoh/compiler.rb
70
73
  - lib/ruhoh/converters/converter.rb
71
74
  - lib/ruhoh/db.rb
75
+ - lib/ruhoh/deployers/s3.rb
76
+ - lib/ruhoh/friend.rb
72
77
  - lib/ruhoh/page.rb
78
+ - lib/ruhoh/parsers/drafts.rb
73
79
  - lib/ruhoh/parsers/layouts.rb
74
80
  - lib/ruhoh/parsers/pages.rb
75
81
  - lib/ruhoh/parsers/partials.rb
76
82
  - lib/ruhoh/parsers/posts.rb
77
83
  - lib/ruhoh/parsers/routes.rb
78
84
  - lib/ruhoh/parsers/site.rb
79
- - lib/ruhoh/preview.rb
80
- - lib/ruhoh/templaters/helper_mustache.rb
81
- - lib/ruhoh/templaters/templater.rb
85
+ - lib/ruhoh/previewer.rb
86
+ - lib/ruhoh/templaters/base.rb
87
+ - lib/ruhoh/templaters/helpers.rb
88
+ - lib/ruhoh/templaters/rmustache.rb
82
89
  - lib/ruhoh/utils.rb
83
90
  - lib/ruhoh/version.rb
84
91
  - lib/ruhoh/watch.rb
85
92
  - ruhoh.gemspec
86
- homepage: http://github.com/plusjade/ruhoh.rb
93
+ - scaffolds/blog/_config.yml
94
+ - scaffolds/blog/_drafts/.gitkeep
95
+ - scaffolds/blog/_posts/.gitkeep
96
+ - scaffolds/blog/_site.yml
97
+ - scaffolds/blog/_templates/partials/categories_list
98
+ - scaffolds/blog/_templates/partials/pages_list
99
+ - scaffolds/blog/_templates/partials/posts_collate
100
+ - scaffolds/blog/_templates/partials/posts_list
101
+ - scaffolds/blog/_templates/partials/tags_list
102
+ - scaffolds/blog/_templates/syntax/google_prettify/default.css
103
+ - scaffolds/blog/_templates/syntax/google_prettify/desert.css
104
+ - scaffolds/blog/_templates/syntax/google_prettify/sons-of-obsidian.css
105
+ - scaffolds/blog/_templates/syntax/google_prettify/sunburst.css
106
+ - scaffolds/blog/_templates/syntax/google_prettify/twitter-bootstrap.css
107
+ - scaffolds/blog/_templates/themes/twitter/bootstrap/css/bootstrap.min.css
108
+ - scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings-white.png
109
+ - scaffolds/blog/_templates/themes/twitter/bootstrap/img/glyphicons-halflings.png
110
+ - scaffolds/blog/_templates/themes/twitter/css/style.css
111
+ - scaffolds/blog/_templates/themes/twitter/layouts/default.html
112
+ - scaffolds/blog/_templates/themes/twitter/layouts/page.html
113
+ - scaffolds/blog/_templates/themes/twitter/layouts/post.html
114
+ - scaffolds/blog/_templates/themes/twitter/manifest.yml
115
+ - scaffolds/blog/about.md
116
+ - scaffolds/blog/archive.html
117
+ - scaffolds/blog/categories.html
118
+ - scaffolds/blog/config.ru
119
+ - scaffolds/blog/index.html
120
+ - scaffolds/blog/pages.html
121
+ - scaffolds/blog/tags.html
122
+ - scaffolds/layout.html
123
+ - scaffolds/page.html
124
+ - scaffolds/post.html
125
+ - scaffolds/theme/css/style.css
126
+ - scaffolds/theme/images/.gitkeep
127
+ - scaffolds/theme/layouts/default.html
128
+ - scaffolds/theme/layouts/page.html
129
+ - scaffolds/theme/layouts/post.html
130
+ - scaffolds/theme/partials/.gitkeep
131
+ - spec/db_spec.rb
132
+ - spec/page_spec.rb
133
+ - spec/parsers/layouts_spec.rb
134
+ - spec/parsers/pages_spec.rb
135
+ - spec/parsers/posts_spec.rb
136
+ - spec/parsers/routes_spec.rb
137
+ - spec/parsers/site_spec.rb
138
+ - spec/setup_spec.rb
139
+ - spec/spec_helper.rb
140
+ - system_partials/analytics/getclicky
141
+ - system_partials/analytics/google
142
+ - system_partials/comments/disqus
143
+ - system_partials/comments/facebook
144
+ - system_partials/comments/intensedebate
145
+ - system_partials/comments/livefyre
146
+ - system_partials/syntax/google_prettify
147
+ homepage: http://github.com/ruhoh/ruhoh.rb
87
148
  licenses:
88
149
  - http://unlicense.org/
89
150
  post_install_message:
data/lib/ruhoh/client.rb DELETED
@@ -1,28 +0,0 @@
1
- class Ruhoh
2
-
3
- module Client
4
- Root = File.expand_path(File.join(File.dirname(__FILE__), '../..'))
5
-
6
- def self.new_blog(name)
7
- if name.nil?
8
- puts "Name must be specified"
9
- exit 0
10
- end
11
-
12
- source_directory = File.join(Root, 'scaffolds/blog')
13
- target_directory = File.join(Dir.pwd, name)
14
-
15
- if File.exist?(target_directory)
16
- puts "#{target_directory} already exists. Specify another directory."
17
- exit 0
18
- end
19
-
20
- FileUtils.mkdir target_directory
21
- FileUtils.cp_r "#{source_directory}/.", target_directory
22
-
23
- puts "=> Blog successfully cloned to:"
24
- puts "=> #{target_directory}"
25
- end
26
- end
27
-
28
- end #Ruhoh
data/lib/ruhoh/preview.rb DELETED
@@ -1,36 +0,0 @@
1
- class Ruhoh
2
-
3
- # Public: Rack application used to render singular pages via their URL.
4
- #
5
- # Examples
6
- #
7
- # In config.ru:
8
- #
9
- # require 'ruhoh'
10
- #
11
- # Ruhoh.setup
12
- # use Rack::Static, {:root => '.', :urls => ['/_media', "/#{Ruhoh.folders.templates}"]}
13
- # run Ruhoh::Preview.new
14
- #
15
- class Preview
16
-
17
- def initialize
18
- Ruhoh::DB.initialize
19
- @page = Ruhoh::Page.new
20
- Ruhoh::Watch.start
21
- end
22
-
23
- def call(env)
24
- return favicon if env['PATH_INFO'] == '/favicon.ico'
25
-
26
- @page.change_with_url(env['PATH_INFO'])
27
- [200, {'Content-Type' => 'text/html'}, [@page.render]]
28
- end
29
-
30
- def favicon
31
- [200, {'Content-Type' => 'image/x-icon'}, ['']]
32
- end
33
-
34
- end #Preview
35
-
36
- end #Ruhoh
@@ -1,109 +0,0 @@
1
- require 'pp'
2
-
3
- class Ruhoh
4
-
5
- class HelperMustache < Mustache
6
-
7
- class HelperContext < Context
8
-
9
- # Overload find method to catch helper expressions
10
- def find(obj, key, default = nil)
11
- return super unless key.to_s.index('?')
12
-
13
- puts "=> Executing helper: #{key}"
14
- context, helper = key.to_s.split('?')
15
- context = context.empty? ? obj : super(obj, context)
16
-
17
- self.mustache_in_stack.__send__ helper, context
18
- end
19
-
20
- end #HelperContext
21
-
22
- def context
23
- @context ||= HelperContext.new(self)
24
- end
25
-
26
- def partial(name)
27
- Ruhoh::DB.partials[name.to_s]
28
- end
29
-
30
- def debug(sub_context)
31
- puts "=>DEBUG:"
32
- puts sub_context.class
33
- puts sub_context.inspect
34
- "<pre>#{sub_context.class}\n#{sub_context.pretty_inspect}</pre>"
35
- end
36
-
37
- def to_tags(sub_context)
38
- if sub_context.is_a?(Array)
39
- sub_context.map { |id|
40
- self.context['_posts']['tags'][id] if self.context['_posts']['tags'][id]
41
- }
42
- else
43
- tags = []
44
- self.context['_posts']['tags'].each_value { |tag|
45
- tags << tag
46
- }
47
- tags
48
- end
49
- end
50
-
51
- def to_posts(sub_context)
52
- sub_context = sub_context.is_a?(Array) ? sub_context : self.context['_posts']['chronological']
53
-
54
- sub_context.map { |id|
55
- self.context['_posts']['dictionary'][id] if self.context['_posts']['dictionary'][id]
56
- }
57
- end
58
-
59
- def to_pages(sub_context)
60
- puts "=> call: pages_list with context: #{sub_context}"
61
- pages = []
62
- if sub_context.is_a?(Array)
63
- sub_context.each do |id|
64
- if self.context[:pages][id]
65
- pages << self.context[:pages][id]
66
- end
67
- end
68
- else
69
- self.context[:pages].each_value {|page| pages << page }
70
- end
71
- pages
72
- end
73
-
74
- def to_categories(sub_context)
75
- if sub_context.is_a?(Array)
76
- sub_context.map { |id|
77
- self.context['_posts']['categories'][id] if self.context['_posts']['categories'][id]
78
- }
79
- else
80
- cats = []
81
- self.context['_posts']['categories'].each_value { |cat|
82
- cats << cat
83
- }
84
- cats
85
- end
86
- end
87
-
88
- def analytics
89
- analytics_config = self.context['site']['config']['analytics']
90
- return '' unless analytics_config && analytics_config['provider']
91
- code = self.partial("analytics-providers/#{analytics_config['provider']}")
92
- return "<h2 style='color:red'>!Analytics Provider partial for '#{analytics_config['provider']}' not found </h2>" if code.nil?
93
-
94
- self.render(code)
95
- end
96
-
97
- def comments
98
- comments_config = self.context['site']['config']['comments']
99
- return '' unless comments_config && comments_config['provider']
100
- code = self.partial("comments-providers/#{comments_config['provider']}")
101
- puts "comments-provders/#{comments_config['provider']}"
102
- return "<h2 style='color:red'>!Comments Provider partial for '#{comments_config['provider']}' not found </h2>" if code.nil?
103
-
104
- self.render(code)
105
- end
106
-
107
- end #HelperMustache
108
-
109
- end #Ruhoh
@@ -1,39 +0,0 @@
1
- class Ruhoh
2
-
3
- module Templater
4
-
5
- def self.build_payload(page)
6
- {
7
- "page" => page.attributes,
8
- "site" => Ruhoh::DB.site,
9
- "pages" => Ruhoh::DB.pages,
10
- "_posts" => Ruhoh::DB.posts,
11
- "ASSET_PATH" => Ruhoh.config.asset_path
12
- }
13
- end
14
-
15
- def self.expand_and_render(page)
16
- self.render(self.expand(page), page)
17
- end
18
-
19
- def self.render(output, page)
20
- Ruhoh::HelperMustache.render(output, self.build_payload(page))
21
- end
22
-
23
- # Expand the page.
24
- # Places page content into sub-template then into master template if available.
25
- def self.expand(page)
26
- output = page.sub_layout['content'].gsub(Ruhoh::Utils::ContentRegex, page.content)
27
-
28
- # An undefined master means the page/post layouts is only one deep.
29
- # This means it expects to load directly into a master template.
30
- if page.master_layout && page.master_layout['content']
31
- output = page.master_layout['content'].gsub(Ruhoh::Utils::ContentRegex, output);
32
- end
33
-
34
- output
35
- end
36
-
37
- end #Templater
38
-
39
- end #Ruhoh