ruhoh 0.3.0 → 1.0.0.alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/Gemfile +1 -0
  2. data/README.md +0 -33
  3. data/dash.html +1 -0
  4. data/history.json +29 -0
  5. data/lib/ruhoh/client/client.rb +30 -22
  6. data/lib/ruhoh/client/help.yml +6 -2
  7. data/lib/ruhoh/compiler.rb +8 -20
  8. data/lib/ruhoh/compilers/rss.rb +36 -0
  9. data/lib/ruhoh/compilers/theme.rb +41 -0
  10. data/lib/ruhoh/config.rb +49 -0
  11. data/lib/ruhoh/converters/converter.rb +17 -4
  12. data/lib/ruhoh/converters/markdown.rb +2 -2
  13. data/lib/ruhoh/db.rb +29 -2
  14. data/lib/ruhoh/deployers/s3.rb +1 -1
  15. data/lib/ruhoh/logger.rb +1 -1
  16. data/lib/ruhoh/page.rb +38 -22
  17. data/lib/ruhoh/parsers/javascripts.rb +67 -0
  18. data/lib/ruhoh/parsers/layouts.rb +6 -10
  19. data/lib/ruhoh/parsers/pages.rb +17 -24
  20. data/lib/ruhoh/parsers/partials.rb +6 -14
  21. data/lib/ruhoh/parsers/payload.rb +47 -0
  22. data/lib/ruhoh/parsers/posts.rb +27 -29
  23. data/lib/ruhoh/parsers/site.rb +2 -2
  24. data/lib/ruhoh/parsers/stylesheets.rb +75 -0
  25. data/lib/ruhoh/parsers/widgets.rb +104 -0
  26. data/lib/ruhoh/paths.rb +75 -0
  27. data/lib/ruhoh/previewer.rb +11 -5
  28. data/lib/ruhoh/program.rb +35 -4
  29. data/lib/ruhoh/templaters/asset_helpers.rb +66 -0
  30. data/lib/ruhoh/templaters/base_helpers.rb +143 -0
  31. data/lib/ruhoh/templaters/helpers.rb +1 -148
  32. data/lib/ruhoh/templaters/rmustache.rb +45 -4
  33. data/lib/ruhoh/urls.rb +46 -0
  34. data/lib/ruhoh/utils.rb +59 -17
  35. data/lib/ruhoh/version.rb +2 -2
  36. data/lib/ruhoh/watch.rb +26 -14
  37. data/lib/ruhoh.rb +38 -96
  38. data/ruhoh.gemspec +29 -10
  39. data/scaffolds/draft.html +9 -0
  40. data/scaffolds/page.html +0 -2
  41. data/scaffolds/post.html +0 -4
  42. data/scaffolds/theme/{images → javascripts}/.gitkeep +0 -0
  43. data/scaffolds/theme/layouts/default.html +2 -4
  44. data/scaffolds/theme/layouts/page.html +1 -1
  45. data/scaffolds/theme/layouts/post.html +1 -1
  46. data/scaffolds/theme/{css/style.css → media/.gitkeep} +0 -0
  47. data/scaffolds/theme/stylesheets/style.css +0 -0
  48. data/scaffolds/theme/theme.yml +27 -0
  49. data/scaffolds/theme/widgets/.gitkeep +0 -0
  50. data/spec/config_spec.rb +50 -0
  51. data/spec/db_spec.rb +28 -14
  52. data/spec/page_spec.rb +24 -35
  53. data/spec/parsers/layouts_spec.rb +5 -13
  54. data/spec/parsers/pages_spec.rb +13 -11
  55. data/spec/parsers/posts_spec.rb +34 -29
  56. data/spec/parsers/routes_spec.rb +2 -1
  57. data/spec/parsers/site_spec.rb +6 -5
  58. data/spec/setup_spec.rb +3 -47
  59. data/widgets/analytics/config.yml +5 -0
  60. data/{system_partials/analytics/getclicky → widgets/analytics/layouts/getclicky.html} +2 -2
  61. data/{system_partials/analytics/google → widgets/analytics/layouts/google.html} +1 -1
  62. data/widgets/comments/config.yml +12 -0
  63. data/{system_partials/comments/disqus → widgets/comments/layouts/disqus.html} +2 -2
  64. data/{system_partials/comments/facebook → widgets/comments/layouts/facebook.html} +1 -1
  65. data/{system_partials/comments/intensedebate → widgets/comments/layouts/intensedebate.html} +1 -1
  66. data/{system_partials/comments/livefyre → widgets/comments/layouts/livefyre.html} +1 -1
  67. data/widgets/google_prettify/config.yml +1 -0
  68. data/widgets/google_prettify/layouts/google_prettify.html +10 -0
  69. metadata +54 -31
  70. data/lib/ruhoh/templaters/base.rb +0 -57
  71. data/system_partials/syntax/google_prettify +0 -11
data/lib/ruhoh/utils.rb CHANGED
@@ -1,11 +1,9 @@
1
1
  class Ruhoh
2
-
3
2
  module Utils
4
3
 
5
4
  FMregex = /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
6
- ContentRegex = /\{\{\s*content\s*\}\}/i
7
5
 
8
- def self.parse_file_as_yaml(*args)
6
+ def self.parse_yaml_file(*args)
9
7
  filepath = File.__send__ :join, args
10
8
  return nil unless File.exist? filepath
11
9
 
@@ -17,20 +15,23 @@ class Ruhoh
17
15
  nil
18
16
  end
19
17
 
20
- def self.parse_file(*args)
18
+ def self.parse_page_file(*args)
21
19
  path = File.__send__(:join, args)
22
-
23
20
  raise "File not found: #{path}" unless File.exist?(path)
24
21
 
25
22
  page = File.open(path, 'r:UTF-8') {|f| f.read }
26
- front_matter = page.match(FMregex)
27
-
28
- return {} unless front_matter
29
-
30
- data = YAML.load(front_matter[0].gsub(/---\n/, "")) || {}
31
23
 
24
+ front_matter = page.match(FMregex)
25
+ if front_matter
26
+ data = YAML.load(front_matter[0].gsub(/---\n/, "")) || {}
27
+ data['categories'] = Array(data['categories'])
28
+ data['tags'] = Array(data['tags'])
29
+ else
30
+ data = {}
31
+ end
32
+
32
33
  {
33
- "data" => self.format_meta(data),
34
+ "data" => data,
34
35
  "content" => page.gsub(FMregex, '')
35
36
  }
36
37
  rescue Psych::SyntaxError => e
@@ -38,13 +39,36 @@ class Ruhoh
38
39
  nil
39
40
  end
40
41
 
41
- def self.format_meta(data)
42
- data['categories'] = Array(data['categories'])
43
- data['tags'] = Array(data['tags'])
44
- data
42
+ def self.parse_layout_file(*args)
43
+ path = File.__send__(:join, args)
44
+ raise "Layout file not found: #{path}" unless File.exist?(path)
45
+ data = {}
46
+ page = File.open(path, 'r:UTF-8') {|f| f.read }
47
+
48
+ front_matter = page.match(FMregex)
49
+ if front_matter
50
+ data = YAML.load(front_matter[0].gsub(/---\n/, "")) || {}
51
+ end
52
+
53
+ {
54
+ "data" => data,
55
+ "content" => page.gsub(FMregex, '')
56
+ }
57
+ rescue Psych::SyntaxError => e
58
+ Ruhoh.log.error("ERROR in #{path}: #{e.message}")
59
+ nil
45
60
  end
46
61
 
47
-
62
+ def self.relative_path(filename)
63
+ filename.gsub(Regexp.new("^#{Ruhoh.paths.base}/"), '')
64
+ end
65
+
66
+ def self.url_to_path(url, base=nil)
67
+ parts = url.split('/')
68
+ parts = parts.unshift(base) if base
69
+ File.__send__(:join, parts)
70
+ end
71
+
48
72
  def self.report(name, collection, invalid)
49
73
  output = "#{collection.count}/#{collection.count + invalid.count} #{name} processed."
50
74
  if collection.empty? && invalid.empty?
@@ -59,6 +83,24 @@ class Ruhoh
59
83
  end
60
84
  end
61
85
 
86
+ # Merges hash with another hash, recursively.
87
+ #
88
+ # Adapted from Jekyll which got it from some gem whose link is now broken.
89
+ # Thanks to whoever made it.
90
+ def self.deep_merge(hash1, hash2)
91
+ target = hash1.dup
92
+
93
+ hash2.keys.each do |key|
94
+ if hash2[key].is_a? Hash and hash1[key].is_a? Hash
95
+ target[key] = self.deep_merge(target[key], hash2[key])
96
+ next
97
+ end
98
+
99
+ target[key] = hash2[key]
100
+ end
101
+
102
+ target
103
+ end
104
+
62
105
  end
63
-
64
106
  end #Ruhoh
data/lib/ruhoh/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  class Ruhoh
2
- Version = VERSION = '0.3.0'
3
- RuhohSpec = '0.2'
2
+ Version = VERSION = '1.0.0.alpha'
3
+ RuhohSpec = '1.0'
4
4
  end
data/lib/ruhoh/watch.rb CHANGED
@@ -11,46 +11,58 @@ class Ruhoh
11
11
  def self.start
12
12
  Ruhoh.ensure_setup
13
13
  Ruhoh::Friend.say {
14
- plain "=> Start watching: #{Ruhoh.paths.site_source}"
14
+ plain "=> Start watching: #{Ruhoh.paths.base}"
15
15
  }
16
16
  glob = ''
17
17
 
18
18
  # Watch all files + all sub directories except for special folders e.g '_database'
19
- Dir.chdir(Ruhoh.paths.site_source) {
19
+ Dir.chdir(Ruhoh.paths.base) {
20
20
  dirs = Dir['*'].select { |x| File.directory?(x) }
21
- dirs -= [Ruhoh.folders.database]
22
21
  dirs = dirs.map { |x| "#{x}/**/*" }
23
22
  dirs += ['*']
24
23
  glob = dirs
25
24
  }
26
25
 
27
- dw = DirectoryWatcher.new(Ruhoh.paths.site_source, {
26
+ dw = DirectoryWatcher.new(Ruhoh.paths.base, {
28
27
  :glob => glob,
29
28
  :pre_load => true
30
29
  })
31
30
  dw.interval = 1
32
31
  dw.add_observer {|*args|
33
32
  args.each {|event|
34
- path = event['path'].gsub(Ruhoh.paths.site_source, '')
33
+ path = event['path'].gsub(Ruhoh.paths.base + '/', '')
35
34
 
36
- if path == "/#{Ruhoh.files.site}"
35
+ if path == Ruhoh.names.site_data
37
36
  type = "Site"
38
37
  Ruhoh::DB.update(:site)
39
- elsif path == "/#{Ruhoh.files.config}"
38
+ elsif path == Ruhoh.names.config_data
40
39
  type = "Config"
41
40
  Ruhoh::DB.update(:site)
42
- elsif path =~ Regexp.new("^\/?#{Ruhoh.folders.posts}")
41
+ elsif path =~ Regexp.new("^#{Ruhoh.names.pages}")
42
+ type = "Pages"
43
+ Ruhoh::DB.update(:pages)
44
+ Ruhoh::DB.update(:routes)
45
+ elsif path =~ Regexp.new("^(#{Ruhoh.names.partials}|#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}\/#{Ruhoh.names.partials})")
46
+ type = "Partials"
47
+ Ruhoh::DB.update(:partials)
48
+ elsif path =~ Regexp.new("^#{Ruhoh.names.posts}")
43
49
  type = "Posts"
44
50
  Ruhoh::DB.update(:posts)
45
51
  Ruhoh::DB.update(:routes)
46
- elsif path =~ Regexp.new("^\/?#{Ruhoh.folders.templates}")
47
- type = "Themes"
52
+ elsif path =~ Regexp.new("^#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}\/#{Ruhoh.names.layouts}")
53
+ type = "Layouts"
48
54
  Ruhoh::DB.update(:layouts)
49
- Ruhoh::DB.update(:partials)
55
+ elsif path =~ Regexp.new("^#{Ruhoh.names.themes}\/#{Ruhoh.config.theme}")
56
+ type = "Theme"
57
+ Ruhoh::DB.update(:stylesheets)
58
+ Ruhoh::DB.update(:javascripts)
59
+ Ruhoh::DB.update(:widgets)
60
+ Ruhoh::DB.update(:layouts)
61
+ elsif path =~ Regexp.new("^#{Ruhoh.names.widgets}")
62
+ type = "Widgets"
63
+ Ruhoh::DB.update(:widgets)
50
64
  else
51
- type = "Pages"
52
- Ruhoh::DB.update(:pages)
53
- Ruhoh::DB.update(:routes)
65
+ type = 'Unrecognized'
54
66
  end
55
67
 
56
68
  Ruhoh::Friend.say {
data/lib/ruhoh.rb CHANGED
@@ -8,23 +8,18 @@ require 'json'
8
8
  require 'time'
9
9
  require 'cgi'
10
10
  require 'fileutils'
11
+ require 'ostruct'
11
12
 
12
13
  require 'mustache'
13
14
 
14
15
  require 'ruhoh/logger'
15
16
  require 'ruhoh/utils'
16
17
  require 'ruhoh/friend'
17
- require 'ruhoh/parsers/posts'
18
- require 'ruhoh/parsers/pages'
19
- require 'ruhoh/parsers/routes'
20
- require 'ruhoh/parsers/layouts'
21
- require 'ruhoh/parsers/partials'
22
- require 'ruhoh/parsers/site'
18
+ require 'ruhoh/config'
19
+ require 'ruhoh/paths'
20
+ require 'ruhoh/urls'
23
21
  require 'ruhoh/db'
24
- require 'ruhoh/templaters/helpers'
25
22
  require 'ruhoh/templaters/rmustache'
26
- require 'ruhoh/templaters/base'
27
- require 'ruhoh/converters/markdown'
28
23
  require 'ruhoh/converters/converter'
29
24
  require 'ruhoh/page'
30
25
  require 'ruhoh/previewer'
@@ -35,97 +30,52 @@ class Ruhoh
35
30
 
36
31
  class << self
37
32
  attr_accessor :log
38
- attr_reader :folders, :files, :config, :paths, :filters
33
+ attr_reader :config, :names, :paths, :root, :urls
39
34
  end
40
35
 
41
36
  @log = Ruhoh::Logger.new
42
-
43
- Root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
44
- Folders = Struct.new(:database, :pages, :posts, :templates, :themes, :layouts, :partials, :media, :syntax, :compiled, :plugins)
45
- Files = Struct.new(:site, :config, :dashboard)
46
- Filters = Struct.new(:posts, :pages, :static)
47
- Config = Struct.new(:permalink, :pages_permalink, :theme, :theme_path, :media_path, :syntax_path, :exclude, :env)
48
- Paths = Struct.new(
49
- :site_source, :database, :pages, :posts, :theme, :layouts, :partials, :global_partials, :media, :syntax,
50
- :compiled, :dashboard, :plugins)
51
-
37
+ Root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
38
+ Names = {
39
+ :assets => 'assets',
40
+ :config_data => 'config.yml',
41
+ :compiled => 'compiled',
42
+ :dashboard_file => 'dash.html',
43
+ :layouts => 'layouts',
44
+ :media => 'media',
45
+ :pages => 'pages',
46
+ :partials => 'partials',
47
+ :plugins => 'plugins',
48
+ :posts => 'posts',
49
+ :javascripts => 'javascripts',
50
+ :site_data => 'site.yml',
51
+ :stylesheets => 'stylesheets',
52
+ :themes => 'themes',
53
+ :theme_config => 'theme.yml',
54
+ :widgets => 'widgets',
55
+ :widget_config => 'config.yml'
56
+ }
57
+ @names = OpenStruct.new(Names)
58
+ @root = Root
52
59
 
53
60
  # Public: Setup Ruhoh utilities relative to the current application directory.
54
61
  # Returns boolean on success/failure
55
62
  def self.setup(opts={})
56
- @log.log_file = opts[:log_file] if opts[:log_file]
57
63
  self.reset
58
- @site_source = opts[:source] if opts[:source]
59
-
60
- if (self.setup_config && self.setup_paths && self.setup_filters)
61
- self.setup_plugins unless opts[:enable_plugins] == false
62
- true
63
- else
64
- false
65
- end
66
- end
67
-
68
- def self.reset
69
- @folders = Folders.new('_database', '_pages', '_posts', '_templates', 'themes', 'layouts', 'partials', "_media", "syntax", '_compiled', '_plugins')
70
- @files = Files.new('_site.yml', '_config.yml', 'dash.html')
71
- @filters = Filters.new
72
- @config = Config.new
73
- @paths = Paths.new
74
- @site_source = Dir.getwd
75
- end
76
-
77
- def self.setup_config
78
- site_config = Ruhoh::Utils.parse_file_as_yaml(@site_source, @files.config)
79
-
80
- unless site_config
81
- Ruhoh.log.error("Empty site_config.\nEnsure ./#{Ruhoh.files.config} exists and contains valid YAML")
82
- return false
83
- end
84
-
85
- theme = site_config['theme'] ? site_config['theme'].to_s.gsub(/\s/, '') : ''
86
- if theme.empty?
87
- Ruhoh.log.error("Theme not specified in _config.yml")
88
- return false
89
- end
64
+ @log.log_file = opts[:log_file] if opts[:log_file]
65
+ @base = opts[:source] if opts[:source]
90
66
 
91
- @config.theme = theme
92
- @config.theme_path = File.join('/', @folders.templates, @folders.themes, @config.theme)
93
- @config.media_path = File.join('/', @folders.media)
94
- @config.syntax_path = File.join('/', @folders.templates, @folders.syntax)
95
- @config.permalink = site_config['permalink']
96
- @config.pages_permalink = site_config['pages']['permalink'] rescue nil
97
- excluded_pages = site_config['pages']['exclude'] rescue nil
98
- @config.exclude = {
99
- "posts" => Array(site_config['exclude'] || nil),
100
- "pages" => Array(excluded_pages),
101
- }
102
- @config.env = site_config['env'] || nil
103
- @config
104
- end
105
-
106
- def self.setup_paths
107
- @paths.site_source = @site_source
108
- @paths.database = self.absolute_path(@folders.database)
109
- @paths.pages = self.absolute_path(@folders.pages)
110
- @paths.posts = self.absolute_path(@folders.posts)
67
+ @config = Ruhoh::Config.generate(@names.config_data)
68
+ @paths = Ruhoh::Paths.generate(@config, @base)
69
+ @urls = Ruhoh::Urls.generate(@config)
111
70
 
112
- @paths.theme = self.absolute_path(@folders.templates, @folders.themes, @config.theme)
113
- @paths.layouts = self.absolute_path(@folders.templates, @folders.themes, @config.theme, @folders.layouts)
114
- @paths.partials = self.absolute_path(@folders.templates, @folders.themes, @config.theme, @folders.partials)
115
- @paths.global_partials = self.absolute_path(@folders.templates, @folders.partials)
116
- @paths.media = self.absolute_path(@folders.media)
117
- @paths.syntax = self.absolute_path(@folders.templates, @folders.syntax)
118
- @paths.compiled = self.absolute_path(@folders.compiled)
119
- @paths.dashboard = self.absolute_path(@files.dashboard)
120
- @paths.plugins = self.absolute_path(@folders.plugins)
121
- @paths
71
+ return false unless(@config && @paths && @urls)
72
+
73
+ self.setup_plugins unless opts[:enable_plugins] == false
74
+ true
122
75
  end
123
76
 
124
- # filename filters
125
- def self.setup_filters
126
- @filters.pages = @config.exclude['pages'].map {|node| Regexp.new(node) }
127
- @filters.posts = @config.exclude['posts'].map {|node| Regexp.new(node) }
128
- @filters
77
+ def self.reset
78
+ @base = Dir.getwd
129
79
  end
130
80
 
131
81
  def self.setup_plugins
@@ -133,14 +83,6 @@ class Ruhoh
133
83
  plugins.each {|f| require f } unless plugins.empty?
134
84
  end
135
85
 
136
- def self.absolute_path(*args)
137
- File.__send__ :join, args.unshift(self.paths.site_source)
138
- end
139
-
140
- def self.relative_path(filename)
141
- filename.gsub( Regexp.new("^#{self.paths.site_source}/"), '' )
142
- end
143
-
144
86
  def self.ensure_setup
145
87
  raise 'Ruhoh has not been setup. Please call: Ruhoh.setup' unless Ruhoh.config && Ruhoh.paths
146
88
  end
data/ruhoh.gemspec CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency 'directory_watcher', "~> 1.4"
20
20
  s.add_dependency 'redcarpet', "~> 2.1"
21
21
  s.add_dependency 'psych', "~> 1.3"
22
+ s.add_dependency 'nokogiri', "~> 1.5"
22
23
 
23
24
  # = MANIFEST =
24
25
  s.files = %w[
@@ -32,6 +33,9 @@ Gem::Specification.new do |s|
32
33
  lib/ruhoh/client/client.rb
33
34
  lib/ruhoh/client/help.yml
34
35
  lib/ruhoh/compiler.rb
36
+ lib/ruhoh/compilers/rss.rb
37
+ lib/ruhoh/compilers/theme.rb
38
+ lib/ruhoh/config.rb
35
39
  lib/ruhoh/converters/converter.rb
36
40
  lib/ruhoh/converters/markdown.rb
37
41
  lib/ruhoh/db.rb
@@ -39,30 +43,42 @@ Gem::Specification.new do |s|
39
43
  lib/ruhoh/friend.rb
40
44
  lib/ruhoh/logger.rb
41
45
  lib/ruhoh/page.rb
46
+ lib/ruhoh/parsers/javascripts.rb
42
47
  lib/ruhoh/parsers/layouts.rb
43
48
  lib/ruhoh/parsers/pages.rb
44
49
  lib/ruhoh/parsers/partials.rb
50
+ lib/ruhoh/parsers/payload.rb
45
51
  lib/ruhoh/parsers/posts.rb
46
52
  lib/ruhoh/parsers/routes.rb
47
53
  lib/ruhoh/parsers/site.rb
54
+ lib/ruhoh/parsers/stylesheets.rb
55
+ lib/ruhoh/parsers/widgets.rb
56
+ lib/ruhoh/paths.rb
48
57
  lib/ruhoh/previewer.rb
49
58
  lib/ruhoh/program.rb
50
- lib/ruhoh/templaters/base.rb
59
+ lib/ruhoh/templaters/asset_helpers.rb
60
+ lib/ruhoh/templaters/base_helpers.rb
51
61
  lib/ruhoh/templaters/helpers.rb
52
62
  lib/ruhoh/templaters/rmustache.rb
63
+ lib/ruhoh/urls.rb
53
64
  lib/ruhoh/utils.rb
54
65
  lib/ruhoh/version.rb
55
66
  lib/ruhoh/watch.rb
56
67
  ruhoh.gemspec
68
+ scaffolds/draft.html
57
69
  scaffolds/layout.html
58
70
  scaffolds/page.html
59
71
  scaffolds/post.html
60
- scaffolds/theme/css/style.css
61
- scaffolds/theme/images/.gitkeep
72
+ scaffolds/theme/javascripts/.gitkeep
62
73
  scaffolds/theme/layouts/default.html
63
74
  scaffolds/theme/layouts/page.html
64
75
  scaffolds/theme/layouts/post.html
76
+ scaffolds/theme/media/.gitkeep
65
77
  scaffolds/theme/partials/.gitkeep
78
+ scaffolds/theme/stylesheets/style.css
79
+ scaffolds/theme/theme.yml
80
+ scaffolds/theme/widgets/.gitkeep
81
+ spec/config_spec.rb
66
82
  spec/db_spec.rb
67
83
  spec/page_spec.rb
68
84
  spec/parsers/layouts_spec.rb
@@ -72,13 +88,16 @@ Gem::Specification.new do |s|
72
88
  spec/parsers/site_spec.rb
73
89
  spec/setup_spec.rb
74
90
  spec/spec_helper.rb
75
- system_partials/analytics/getclicky
76
- system_partials/analytics/google
77
- system_partials/comments/disqus
78
- system_partials/comments/facebook
79
- system_partials/comments/intensedebate
80
- system_partials/comments/livefyre
81
- system_partials/syntax/google_prettify
91
+ widgets/analytics/config.yml
92
+ widgets/analytics/layouts/getclicky.html
93
+ widgets/analytics/layouts/google.html
94
+ widgets/comments/config.yml
95
+ widgets/comments/layouts/disqus.html
96
+ widgets/comments/layouts/facebook.html
97
+ widgets/comments/layouts/intensedebate.html
98
+ widgets/comments/layouts/livefyre.html
99
+ widgets/google_prettify/config.yml
100
+ widgets/google_prettify/layouts/google_prettify.html
82
101
  ]
83
102
  # = MANIFEST =
84
103
  end
@@ -0,0 +1,9 @@
1
+ ---
2
+ title:
3
+ date: '{{DATE}}'
4
+ description:
5
+ categories:
6
+ tags: []
7
+
8
+ type: draft
9
+ ---
data/scaffolds/page.html CHANGED
@@ -1,6 +1,4 @@
1
1
  ---
2
2
  title:
3
3
  description:
4
-
5
- layout: page
6
4
  ---
data/scaffolds/post.html CHANGED
@@ -3,8 +3,4 @@ title:
3
3
  date: '{{DATE}}'
4
4
  description:
5
5
  categories:
6
- tags: []
7
-
8
- layout: post
9
- type: draft
10
6
  ---
File without changes
@@ -1,15 +1,13 @@
1
- ---
2
- ---
3
1
  <!DOCTYPE html>
4
2
  <html lang="en">
5
3
  <head>
6
4
  <meta charset="utf-8">
7
- <link href="{{ paths.theme }}/css/style.css" rel="stylesheet" type="text/css" media="all">
5
+ {{{ assets }}}
8
6
  </head>
9
7
  <body>
10
8
 
11
9
  <div class="content">
12
- {{ content }}
10
+ {{{ content }}}
13
11
  </div>
14
12
 
15
13
  {{{ analytics }}}
@@ -4,4 +4,4 @@ layout : default
4
4
 
5
5
  <h1>{{ page.title }}</h1>
6
6
 
7
- {{ content }}
7
+ {{{ content }}}
@@ -2,7 +2,7 @@
2
2
  layout : default
3
3
  ---
4
4
 
5
- {{ content }}
5
+ {{{ content }}}
6
6
 
7
7
  {{{ comments }}}
8
8
 
File without changes
File without changes
@@ -0,0 +1,27 @@
1
+ {
2
+ "stylesheets" : {
3
+ "default" : [
4
+ "style.css"
5
+ ],
6
+
7
+ "page" : [
8
+
9
+ ],
10
+
11
+ "post" : [
12
+
13
+ ],
14
+
15
+ "widgets" : {
16
+
17
+ }
18
+
19
+ },
20
+
21
+ "javascripts" : {
22
+ "default" : [
23
+
24
+ ]
25
+ }
26
+
27
+ }
File without changes
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ module Config
4
+ describe "Config" do
5
+ describe "#setup_config" do
6
+ context "Invalid _config.yml file" do
7
+ it 'should log error and return false if theme is not specified.' do
8
+ Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({})
9
+
10
+ Ruhoh.log.should_receive(:error)
11
+ Ruhoh::Config.generate('config.yml').should be_false
12
+ end
13
+ end
14
+ context "Valid _config.yml file" do
15
+ it 'should setup the config struct based on configuration input.' do
16
+ custom_permalink = '/my/custom/link'
17
+ custom_theme = 'table'
18
+ custom_exclude = ['.secret']
19
+ Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
20
+ "theme" => custom_theme,
21
+ "posts" => {
22
+ "permalink" => custom_permalink,
23
+ 'exclude' => custom_exclude
24
+ }
25
+ })
26
+
27
+ config = Ruhoh::Config.generate('config.yml')
28
+ config.theme.should == custom_theme
29
+ config.posts_exclude.should == [/.secret/]
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#setup_filters" do
35
+ it 'should add custom exclude filters to the filters variable' do
36
+ custom_exclude = ['.secret', '^test']
37
+ Ruhoh::Utils.should_receive(:parse_yaml_file).and_return({
38
+ 'theme' => "twitter",
39
+ "posts" => {
40
+ 'exclude' => custom_exclude
41
+ },
42
+ })
43
+
44
+ config = Ruhoh::Config.generate('config.yml')
45
+ config.posts_exclude.should include(/.secret/)
46
+ config.posts_exclude.should include(/^test/)
47
+ end
48
+ end
49
+ end
50
+ end
data/spec/db_spec.rb CHANGED
@@ -1,21 +1,19 @@
1
- require 'spec_helper'
2
-
3
1
  module DB
4
2
 
5
3
  describe Ruhoh::DB do
6
- let(:whitelist){
7
- [:site, :routes, :posts, :pages, :layouts, :partials]
8
- }
4
+ let(:whitelist){ Ruhoh::DB::WhiteList }
9
5
 
10
6
  before(:each) do
11
- Ruhoh::Utils.stub(:parse_file_as_yaml).and_return({'theme' => "twitter"})
7
+ Ruhoh::Utils.stub(:parse_yaml_file).and_return({'theme' => "twitter"})
8
+ Ruhoh::Paths.stub(:theme_is_valid?).and_return(true)
12
9
  Ruhoh.setup(:source => SampleSitePath)
13
10
  end
14
11
 
15
12
  context "database has not been updated" do
16
- it "should return nil for all whitelisted variables" do
13
+ it "should return nil for all whitelisted variables except payload" do
17
14
  whitelist.each do |var|
18
- result = Ruhoh::DB.__send__ var
15
+ result = Ruhoh::DB.__send__(var)
16
+ next if var == :payload
19
17
  result.should be_nil
20
18
  end
21
19
  end
@@ -62,16 +60,32 @@ module DB
62
60
  Ruhoh::DB.update(:partials)
63
61
  Ruhoh::DB.partials.should == {'test' => 'hi'}
64
62
  end
63
+
64
+ it "should run the widgets parser when updating :widgets" do
65
+ Ruhoh::Parsers::Widgets.should_receive(:generate).and_return({'test' => 'hi'})
66
+ Ruhoh::DB.update(:widgets)
67
+ Ruhoh::DB.widgets.should == {'test' => 'hi'}
68
+ end
69
+
70
+ it "should run the stylesheets parser when updating :stylesheets" do
71
+ Ruhoh::Parsers::Stylesheets.should_receive(:generate).and_return({'test' => 'hi'})
72
+ Ruhoh::DB.update(:stylesheets)
73
+ Ruhoh::DB.stylesheets.should == {'test' => 'hi'}
74
+ end
75
+
76
+ it "should run the scripts parser when updating :javascripts" do
77
+ Ruhoh::Parsers::Javascripts.should_receive(:generate).and_return({'test' => 'hi'})
78
+ Ruhoh::DB.update(:javascripts)
79
+ Ruhoh::DB.javascripts.should == {'test' => 'hi'}
80
+ end
81
+
65
82
  end
66
83
 
67
84
  describe "#update_all" do
68
85
  it "should call update for all WhiteListed variables." do
69
- Ruhoh::DB.should_receive(:update).with(:site).ordered
70
- Ruhoh::DB.should_receive(:update).with(:posts).ordered
71
- Ruhoh::DB.should_receive(:update).with(:pages).ordered
72
- Ruhoh::DB.should_receive(:update).with(:routes).ordered
73
- Ruhoh::DB.should_receive(:update).with(:layouts).ordered
74
- Ruhoh::DB.should_receive(:update).with(:partials).ordered
86
+ whitelist.each do |name|
87
+ Ruhoh::DB.should_receive(:update).with(name).ordered
88
+ end
75
89
  Ruhoh::DB.update_all
76
90
  end
77
91
  end