ruhoh 1.1 → 2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/Gemfile +3 -3
  2. data/README.md +3 -2
  3. data/Rakefile +1 -22
  4. data/bin/ruhoh +1 -5
  5. data/history.json +16 -0
  6. data/lib/ruhoh.rb +229 -84
  7. data/lib/ruhoh/base/collection.rb +280 -0
  8. data/lib/ruhoh/base/compiler.rb +55 -0
  9. data/lib/ruhoh/base/model.rb +220 -0
  10. data/lib/ruhoh/base/model_view.rb +152 -0
  11. data/lib/ruhoh/base/watcher.rb +25 -0
  12. data/lib/ruhoh/cache.rb +46 -0
  13. data/lib/ruhoh/client.rb +162 -0
  14. data/lib/ruhoh/collections.rb +172 -0
  15. data/lib/ruhoh/console_methods.rb +21 -0
  16. data/lib/ruhoh/{converters/converter.rb → converter.rb} +4 -1
  17. data/lib/ruhoh/programs/compile.rb +22 -0
  18. data/lib/ruhoh/programs/preview.rb +63 -0
  19. data/lib/ruhoh/programs/watch.rb +45 -0
  20. data/lib/ruhoh/resources/dash/collection.rb +10 -0
  21. data/lib/ruhoh/resources/dash/model.rb +5 -0
  22. data/lib/ruhoh/resources/dash/model_view.rb +5 -0
  23. data/lib/ruhoh/resources/dash/previewer.rb +13 -0
  24. data/lib/ruhoh/resources/data/collection.rb +9 -0
  25. data/lib/ruhoh/resources/data/collection_view.rb +23 -0
  26. data/lib/ruhoh/resources/javascripts/collection.rb +9 -0
  27. data/lib/ruhoh/resources/javascripts/collection_view.rb +46 -0
  28. data/lib/ruhoh/resources/javascripts/compiler.rb +5 -0
  29. data/lib/ruhoh/resources/layouts/client.rb +45 -0
  30. data/lib/ruhoh/resources/layouts/model.rb +16 -0
  31. data/lib/ruhoh/resources/media/collection.rb +9 -0
  32. data/lib/ruhoh/resources/media/compiler.rb +27 -0
  33. data/lib/ruhoh/resources/pages/client.rb +124 -0
  34. data/lib/ruhoh/resources/pages/collection.rb +86 -0
  35. data/lib/ruhoh/resources/pages/collection_view.rb +73 -0
  36. data/lib/ruhoh/resources/pages/compiler.rb +101 -0
  37. data/lib/ruhoh/resources/pages/model.rb +5 -0
  38. data/lib/ruhoh/resources/pages/model_view.rb +5 -0
  39. data/lib/ruhoh/resources/pages/previewer.rb +72 -0
  40. data/lib/ruhoh/resources/partials/model.rb +11 -0
  41. data/lib/ruhoh/resources/stylesheets/collection.rb +9 -0
  42. data/lib/ruhoh/resources/stylesheets/collection_view.rb +45 -0
  43. data/lib/ruhoh/resources/stylesheets/compiler.rb +5 -0
  44. data/lib/ruhoh/resources/theme/collection.rb +14 -0
  45. data/lib/ruhoh/resources/theme/compiler.rb +54 -0
  46. data/lib/ruhoh/resources/widgets/collection.rb +26 -0
  47. data/lib/ruhoh/resources/widgets/collection_view.rb +34 -0
  48. data/lib/ruhoh/resources/widgets/compiler.rb +27 -0
  49. data/lib/ruhoh/resources/widgets/model.rb +16 -0
  50. data/lib/ruhoh/routes.rb +29 -0
  51. data/lib/ruhoh/utils.rb +32 -49
  52. data/lib/ruhoh/version.rb +2 -2
  53. data/lib/ruhoh/views/helpers/categories.rb +38 -0
  54. data/lib/ruhoh/views/helpers/paginator.rb +39 -0
  55. data/lib/ruhoh/views/helpers/tags.rb +37 -0
  56. data/lib/ruhoh/views/master_view.rb +183 -0
  57. data/lib/ruhoh/views/rmustache.rb +24 -0
  58. data/ruhoh.gemspec +6 -82
  59. data/spec/spec_helper.rb +1 -1
  60. data/spec/support/shared_contexts.rb +6 -5
  61. data/system/{scaffolds/post.html → _scaffold.html} +1 -1
  62. data/system/{dash.html → dash/index.html} +37 -51
  63. data/system/{scaffolds/layout.html → layouts/_scaffold.html} +0 -0
  64. data/system/layouts/paginator.html +28 -0
  65. data/system/plugins/sprockets/javascripts/compiler.rb +25 -0
  66. data/system/plugins/sprockets/javascripts/previewer.rb +17 -0
  67. data/system/plugins/sprockets/stylesheets/compiler.rb +26 -0
  68. data/system/plugins/sprockets/stylesheets/previewer.rb +17 -0
  69. data/system/widgets/analytics/{layouts/getclicky.html → getclicky.html} +6 -2
  70. data/system/widgets/analytics/{layouts/google.html → google.html} +5 -1
  71. data/system/widgets/comments/{layouts/disqus.html → disqus.html} +6 -2
  72. data/system/widgets/comments/{layouts/facebook.html → facebook.html} +9 -2
  73. data/system/widgets/comments/{layouts/intensedebate.html → intensedebate.html} +5 -1
  74. data/system/widgets/comments/{layouts/livefyre.html → livefyre.html} +5 -1
  75. data/system/widgets/google_prettify/{layouts/google_prettify.html → default.html} +6 -2
  76. metadata +69 -66
  77. data/lib/ruhoh/client/client.rb +0 -306
  78. data/lib/ruhoh/client/console_methods.rb +0 -9
  79. data/lib/ruhoh/client/help.yml +0 -56
  80. data/lib/ruhoh/compiler.rb +0 -72
  81. data/lib/ruhoh/compilers/rss.rb +0 -39
  82. data/lib/ruhoh/compilers/theme.rb +0 -46
  83. data/lib/ruhoh/config.rb +0 -62
  84. data/lib/ruhoh/db.rb +0 -50
  85. data/lib/ruhoh/deployers/s3.rb +0 -71
  86. data/lib/ruhoh/page.rb +0 -106
  87. data/lib/ruhoh/parsers/javascripts.rb +0 -55
  88. data/lib/ruhoh/parsers/layouts.rb +0 -32
  89. data/lib/ruhoh/parsers/pages.rb +0 -79
  90. data/lib/ruhoh/parsers/partials.rb +0 -42
  91. data/lib/ruhoh/parsers/payload.rb +0 -49
  92. data/lib/ruhoh/parsers/posts.rb +0 -259
  93. data/lib/ruhoh/parsers/routes.rb +0 -20
  94. data/lib/ruhoh/parsers/scaffolds.rb +0 -35
  95. data/lib/ruhoh/parsers/site.rb +0 -19
  96. data/lib/ruhoh/parsers/stylesheets.rb +0 -63
  97. data/lib/ruhoh/parsers/theme_config.rb +0 -30
  98. data/lib/ruhoh/parsers/widgets.rb +0 -104
  99. data/lib/ruhoh/paths.rb +0 -83
  100. data/lib/ruhoh/previewer.rb +0 -48
  101. data/lib/ruhoh/program.rb +0 -68
  102. data/lib/ruhoh/templaters/asset_helpers.rb +0 -66
  103. data/lib/ruhoh/templaters/base_helpers.rb +0 -147
  104. data/lib/ruhoh/templaters/helpers.rb +0 -8
  105. data/lib/ruhoh/templaters/rmustache.rb +0 -70
  106. data/lib/ruhoh/urls.rb +0 -50
  107. data/lib/ruhoh/watch.rb +0 -78
  108. data/spec/config_spec.rb +0 -50
  109. data/spec/db_spec.rb +0 -91
  110. data/spec/page_spec.rb +0 -164
  111. data/spec/parsers/layouts_spec.rb +0 -41
  112. data/spec/parsers/pages_spec.rb +0 -120
  113. data/spec/parsers/posts_spec.rb +0 -309
  114. data/spec/parsers/routes_spec.rb +0 -39
  115. data/spec/parsers/site_spec.rb +0 -28
  116. data/spec/setup_spec.rb +0 -12
  117. data/system/scaffolds/draft.html +0 -9
  118. data/system/scaffolds/page.html +0 -4
  119. data/system/widgets/analytics/config.yml +0 -5
  120. data/system/widgets/comments/config.yml +0 -13
  121. data/system/widgets/google_prettify/config.yml +0 -1
@@ -1,20 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- module Routes
4
-
5
- def self.generate
6
- routes = {}
7
- Ruhoh::DB.pages.each_value { |page|
8
- routes[page['url']] = page['id']
9
- }
10
-
11
- Ruhoh::DB.posts['dictionary'].each_value { |page|
12
- routes[page['url']] = page['id']
13
- }
14
-
15
- routes
16
- end
17
-
18
- end #Routes
19
- end #Parsers
20
- end #Ruhoh
@@ -1,35 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- module Scaffolds
4
-
5
- def self.generate
6
- self.system_scaffolds.merge(
7
- self.scaffolds
8
- )
9
- end
10
-
11
- def self.scaffolds
12
- self.process(Ruhoh.paths.scaffolds)
13
- end
14
-
15
- def self.system_scaffolds
16
- self.process(Ruhoh.paths.system_scaffolds)
17
- end
18
-
19
- def self.process(path)
20
- return {} unless File.exist?(path)
21
-
22
- scaffolds = {}
23
- FileUtils.cd(path) {
24
- Dir.glob("**/*").each { |filename|
25
- next if FileTest.directory?(filename)
26
- next if ['.'].include? filename[0]
27
- File.open(filename, 'r:UTF-8') { |f| scaffolds[filename] = f.read }
28
- }
29
- }
30
- scaffolds
31
- end
32
-
33
- end #Scaffolds
34
- end #Parsers
35
- end #Ruhoh
@@ -1,19 +0,0 @@
1
- class Ruhoh
2
-
3
- module Parsers
4
-
5
- # Sitewide data hash + configuration file.
6
- module Site
7
-
8
- def self.generate
9
- site = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.site_data) || {}
10
- config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.config_data)
11
- site['config'] = config
12
- site
13
- end
14
-
15
- end #Site
16
-
17
- end #Parsers
18
-
19
- end #Ruhoh
@@ -1,63 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- # Collect all registered stylesheets.
4
- # Themes explicitly define which stylesheets to load via theme.yml.
5
- # All styling is managed by the theme, including widget styles.
6
- # If the theme provides widget stylesheets they will load automatically.
7
- # theme.yml may also specify an explicit widget stylesheet to load.
8
- module Stylesheets
9
-
10
- # Generates mappings to all registered stylesheets.
11
- # Returns Hash with layout names as keys and Array of asset Objects as values
12
- def self.generate
13
- assets = self.theme_stylesheets
14
- assets[Ruhoh.names.widgets] = self.widget_stylesheets
15
- assets
16
- end
17
-
18
- # Create mappings for stylesheets registered to the theme layouts.
19
- # Themes register stylesheets relative to their layouts.
20
- # Returns Hash with layout names as keys and Array of asset Objects as values.
21
- def self.theme_stylesheets
22
- return {} unless Ruhoh::DB.theme_config[Ruhoh.names.stylesheets].is_a? Hash
23
- assets = {}
24
- Ruhoh::DB.theme_config[Ruhoh.names.stylesheets].each do |key, value|
25
- next if key == Ruhoh.names.widgets # Widgets are handled separately.
26
- assets[key] = Array(value).map { |v|
27
- url = (v =~ /^(http:|https:)?\/\//i) ? v : "#{Ruhoh.urls.theme_stylesheets}/#{v}"
28
- {
29
- "url" => url,
30
- "id" => File.join(Ruhoh.paths.theme_stylesheets, v)
31
- }
32
- }
33
- end
34
-
35
- assets
36
- end
37
-
38
- # Create mappings for stylesheets registered to a given widget.
39
- # A theme may provide widget stylesheets which will load automatically,
40
- # provided they adhere to the default naming rules.
41
- # Themes may also specify an explicit widget stylesheet to load.
42
- #
43
- # Returns Array of asset objects.
44
- def self.widget_stylesheets
45
- assets = []
46
- Ruhoh::DB.widgets.each_key do |name|
47
- default_name = "#{name}.css"
48
- stylesheet = Ruhoh::DB.theme_config[Ruhoh.names.stylesheets][Ruhoh.names.widgets][name] rescue default_name
49
- stylesheet ||= default_name
50
- file = File.join(Ruhoh.paths.theme_widgets, name, Ruhoh.names.stylesheets, stylesheet)
51
- next unless File.exists?(file)
52
- assets << {
53
- "url" => [Ruhoh.urls.theme_widgets, name, Ruhoh.names.stylesheets, stylesheet].join('/'),
54
- "id" => file
55
- }
56
- end
57
-
58
- assets
59
- end
60
-
61
- end #Stylesheets
62
- end #Parsers
63
- end #Ruhoh
@@ -1,30 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- module ThemeConfig
4
-
5
- def self.generate
6
- config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.theme_config_data)
7
- if config.nil?
8
- Ruhoh::Friend.say{
9
- yellow "WARNING: theme.yml config file not found:"
10
- yellow " #{Ruhoh.paths.theme_config_data}"
11
- }
12
- return {}
13
- end
14
- return {} unless config.is_a? Hash
15
-
16
- config["exclude"] = Array(config['exclude']).compact.map do |node|
17
- is_last = node[0] == "*"
18
- node = node.chomp("*").reverse.chomp("*").reverse
19
- node = Regexp.escape("#{node}")
20
- node = is_last ? "#{node}$" : "^#{node}"
21
-
22
- Regexp.new(node, true)
23
- end
24
-
25
- config
26
- end
27
-
28
- end #ThemeConfig
29
- end #Parsers
30
- end #Ruhoh
@@ -1,104 +0,0 @@
1
- class Ruhoh
2
- module Parsers
3
- module Widgets
4
- WidgetStructure = Struct.new(
5
- :name,
6
- :config,
7
- :javascripts,
8
- :layout
9
- )
10
-
11
- # Process available widgets into widget dictionary.
12
- #
13
- # Returns Dictionary of widget data.
14
- def self.generate
15
- widgets = {}
16
- self.widgets.each do |name|
17
- config = self.process_config(name)
18
- widgets[name] = WidgetStructure.new(
19
- name,
20
- config,
21
- self.process_javascripts(config, name),
22
- self.process_layout(config, name)
23
- )
24
- end
25
- Ruhoh::Utils.report('Widgets', widgets, [])
26
-
27
- widgets
28
- end
29
-
30
- # Find the widgets.
31
- #
32
- # Returns Array of widget names.
33
- def self.widgets
34
- names = []
35
- if FileTest.directory?(Ruhoh.paths.widgets)
36
- FileUtils.cd(Ruhoh.paths.widgets) { names += Dir["*"] }
37
- end
38
- if FileTest.directory?(Ruhoh.paths.system_widgets)
39
- FileUtils.cd(Ruhoh.paths.system_widgets) { names += Dir["*"] }
40
- end
41
- names.uniq!
42
- names
43
- end
44
-
45
- # Process the widget configuration params.
46
- #
47
- # Returns Hash of configuration params.
48
- def self.process_config(widget_name)
49
- system_config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.system_widgets, widget_name, Ruhoh.names.config_data) || {}
50
- user_config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.widgets, widget_name, Ruhoh.names.config_data) || {}
51
- config = Ruhoh::Utils.deep_merge(system_config, user_config)
52
- config['layout'] ||= widget_name
53
- config['stylesheet'] ||= widget_name
54
- config
55
- end
56
-
57
- # Process widget script dependencies.
58
- # Script dependencies may be set in the config.
59
- # Look for default script at: scripts/{widget_name}.js if no config.
60
- # If found, we include it, else no javascripts will load.
61
- #
62
- # Returns Array of script filenames to load.
63
- def self.process_javascripts(config, widget_name)
64
- scripts = config[Ruhoh.names.javascripts] ? Array(config[Ruhoh.names.javascripts]) : []
65
-
66
- # Try for the default script if no config.
67
- if scripts.empty?
68
- script_file = File.join(Ruhoh.paths.widgets, widget_name, Ruhoh.names.javascripts, "#{widget_name}.js")
69
- if File.exist?(script_file)
70
- scripts << "#{widget_name}.js"
71
- else
72
- script_file = File.join(Ruhoh.paths.system_widgets, widget_name, Ruhoh.names.javascripts, "#{widget_name}.js")
73
- scripts << "#{widget_name}.js" if File.exist?(script_file)
74
- end
75
- end
76
-
77
- scripts
78
- end
79
-
80
- # Determine and process the correct widget layout.
81
- # The layout may be manually configured by the user,
82
- # else system defaults will be used.
83
- # Layouts cascade from: theme -> blog -> system
84
- #
85
- # Returns String of rendered layout content.
86
- def self.process_layout(config, widget_name)
87
- layout = nil
88
- layout_path = File.join(widget_name, 'layouts', "#{config['layout']}.html")
89
- [
90
- File.join(Ruhoh.paths.theme_widgets, layout_path),
91
- File.join(Ruhoh.paths.widgets, layout_path),
92
- File.join(Ruhoh.paths.system_widgets, layout_path)
93
- ].each do |path|
94
- layout = path and break if File.exist?(path)
95
- end
96
-
97
- return '' unless layout
98
- content = File.open(layout, 'r:UTF-8') { |f| f.read }
99
- Mustache.render(content, {'config' => config})
100
- end
101
-
102
- end #Widgets
103
- end #Parsers
104
- end #Ruhoh
data/lib/ruhoh/paths.rb DELETED
@@ -1,83 +0,0 @@
1
- class Ruhoh
2
- # Structured container for all paths to relevant directories and files in the system.
3
- # Paths are based on the ruhohspec for the Universal Blog API.
4
- # Additionally we store some system (gem) level paths for cascading to default functionality,
5
- # such as default widgets, default dashboard view, etc.
6
- module Paths
7
- Paths = Struct.new(
8
- :base,
9
- :compiled,
10
- :config_data,
11
- :dashboard_file,
12
- :media,
13
- :pages,
14
- :partials,
15
- :plugins,
16
- :posts,
17
- :scaffolds,
18
- :site_data,
19
- :themes,
20
- :widgets,
21
-
22
- :theme,
23
- :theme_config_data,
24
- :theme_dashboard_file,
25
- :theme_layouts,
26
- :theme_media,
27
- :theme_partials,
28
- :theme_javascripts,
29
- :theme_stylesheets,
30
- :theme_widgets,
31
-
32
- :system,
33
- :system_dashboard_file,
34
- :system_scaffolds,
35
- :system_partials,
36
- :system_widgets
37
- )
38
-
39
- def self.generate
40
- paths = Paths.new
41
- paths.base = Ruhoh.base
42
- paths.config_data = File.join(Ruhoh.base, Ruhoh.names.config_data)
43
- paths.pages = File.join(Ruhoh.base, Ruhoh.names.pages)
44
- paths.posts = File.join(Ruhoh.base, Ruhoh.names.posts)
45
- paths.partials = File.join(Ruhoh.base, Ruhoh.names.partials)
46
- paths.media = File.join(Ruhoh.base, Ruhoh.names.media)
47
- paths.widgets = File.join(Ruhoh.base, Ruhoh.names.widgets)
48
- paths.compiled = File.join(Ruhoh.base, Ruhoh.names.compiled)
49
- paths.dashboard_file = File.join(Ruhoh.base, Ruhoh.names.dashboard_file)
50
- paths.site_data = File.join(Ruhoh.base, Ruhoh.names.site_data)
51
- paths.themes = File.join(Ruhoh.base, Ruhoh.names.themes)
52
- paths.plugins = File.join(Ruhoh.base, Ruhoh.names.plugins)
53
- paths.scaffolds = File.join(Ruhoh.base, Ruhoh.names.scaffolds)
54
-
55
- paths.theme = File.join(Ruhoh.base, Ruhoh.names.themes, Ruhoh.config.theme)
56
- paths.theme_dashboard_file= File.join(paths.theme, Ruhoh.names.dashboard_file)
57
- paths.theme_config_data = File.join(paths.theme, Ruhoh.names.theme_config)
58
- paths.theme_layouts = File.join(paths.theme, Ruhoh.names.layouts)
59
- paths.theme_stylesheets = File.join(paths.theme, Ruhoh.names.stylesheets)
60
- paths.theme_javascripts = File.join(paths.theme, Ruhoh.names.javascripts)
61
- paths.theme_media = File.join(paths.theme, Ruhoh.names.media)
62
- paths.theme_widgets = File.join(paths.theme, Ruhoh.names.widgets)
63
- paths.theme_partials = File.join(paths.theme, Ruhoh.names.partials)
64
-
65
- return false unless self.theme_is_valid?(paths)
66
-
67
- paths.system = File.join(Ruhoh::Root, Ruhoh.names.system)
68
- paths.system_dashboard_file = File.join(paths.system, Ruhoh.names.dashboard_file)
69
- paths.system_partials = File.join(paths.system, Ruhoh.names.partials)
70
- paths.system_scaffolds = File.join(paths.system, Ruhoh.names.scaffolds)
71
- paths.system_widgets = File.join(paths.system, Ruhoh.names.widgets)
72
-
73
- paths
74
- end
75
-
76
- def self.theme_is_valid?(paths)
77
- return true if FileTest.directory?(paths.theme)
78
- Ruhoh.log.error("Theme directory does not exist: #{paths.theme}")
79
- return false
80
- end
81
-
82
- end #Paths
83
- end #Ruhoh
@@ -1,48 +0,0 @@
1
- class Ruhoh
2
- # Public: Rack application used to render singular pages via their URL.
3
- #
4
- # This class depends on a correctly loaded Ruhoh environment;
5
- # it should only be used as part of a Ruhoh 'program' routine.
6
- # See Ruhoh::Program for usage.
7
- #
8
- class Previewer
9
-
10
- def initialize(page)
11
- Ruhoh.config.env ||= 'development'
12
- @page = page
13
- end
14
-
15
- def call(env)
16
- return favicon if env['PATH_INFO'] == '/favicon.ico'
17
- # Always remove trailing slash if sent unless it's the root page.
18
- env['PATH_INFO'].gsub!(/\/$/, '') unless env['PATH_INFO'] == "/"
19
- return admin if env['PATH_INFO'] == Ruhoh.urls.dashboard
20
-
21
- id = Ruhoh::DB.routes[env['PATH_INFO']]
22
- raise "Page id not found for url: #{env['PATH_INFO']}" unless id
23
- @page.change(id)
24
-
25
- [200, {'Content-Type' => 'text/html'}, [@page.render]]
26
- end
27
-
28
- def favicon
29
- [200, {'Content-Type' => 'image/x-icon'}, ['']]
30
- end
31
-
32
- def admin
33
- template = nil
34
- [
35
- Ruhoh.paths.theme_dashboard_file,
36
- Ruhoh.paths.dashboard_file,
37
- Ruhoh.paths.system_dashboard_file
38
- ].each do |path|
39
- template = path and break if File.exist?(path)
40
- end
41
- template = File.open(template, 'r:UTF-8') {|f| f.read }
42
- output = @page.templater.render(template, Ruhoh::DB.payload)
43
-
44
- [200, {'Content-Type' => 'text/html'}, [output]]
45
- end
46
-
47
- end #Previewer
48
- end #Ruhoh
data/lib/ruhoh/program.rb DELETED
@@ -1,68 +0,0 @@
1
- class Ruhoh
2
- module Program
3
-
4
- # Public: A program for running ruhoh as a rack application
5
- # which renders singular pages via their URL.
6
- #
7
- # Examples
8
- #
9
- # In config.ru:
10
- #
11
- # require 'ruhoh'
12
- # run Ruhoh::Program.preview
13
- #
14
- # Returns: A new Rack builder object which should work inside config.ru
15
- def self.preview(opts={})
16
- opts[:watch] ||= true
17
- opts[:env] ||= 'development'
18
-
19
- Ruhoh.setup
20
- Ruhoh.config.env = opts[:env]
21
- Ruhoh.setup_paths
22
- Ruhoh.setup_urls
23
- Ruhoh.setup_plugins unless opts[:enable_plugins] == false
24
-
25
- Ruhoh::DB.update_all
26
-
27
- Ruhoh::Watch.start if opts[:watch]
28
- Rack::Builder.new {
29
- use Rack::Lint
30
- use Rack::ShowExceptions
31
-
32
- # Serve base media
33
- map Ruhoh.urls.media do
34
- run Rack::File.new(Ruhoh.paths.media)
35
- end
36
-
37
- # Serve theme assets
38
- map Ruhoh.urls.theme do
39
- run Rack::File.new(Ruhoh.paths.theme)
40
- end
41
-
42
- # Serve widget javascripts
43
- map Ruhoh.urls.widgets do
44
- run Rack::File.new(Ruhoh.paths.widgets)
45
- end
46
-
47
- map '/' do
48
- run Ruhoh::Previewer.new(Ruhoh::Page.new)
49
- end
50
- }
51
- end
52
-
53
- # Public: A program for compiling to a static website.
54
- # The compile environment should always be 'production' in order
55
- # to properly omit drafts and other development-only settings.
56
- def self.compile(target)
57
- Ruhoh.setup
58
- Ruhoh.config.env = 'production'
59
- Ruhoh.setup_paths
60
- Ruhoh.setup_urls
61
- Ruhoh.setup_plugins
62
-
63
- Ruhoh::DB.update_all
64
- Ruhoh::Compiler.compile(target)
65
- end
66
-
67
- end #Program
68
- end #Ruhoh