ruhoh 1.0.0.alpha → 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
-
2
1
  ## Ruhoh is the Universal Static Blog API
3
2
 
4
3
  <http://ruhoh.com>
5
4
 
6
5
  ### Usage
6
+ $ gem install ruhoh
7
+ $ ruhoh help
7
8
 
8
- $ gem install ruhoh
9
- $ ruhoh help
data/history.json CHANGED
@@ -1,4 +1,21 @@
1
1
  [
2
+ {
3
+ "version" : "1.0",
4
+ "date" : "22.08.2012",
5
+ "changes" : [
6
+ "Ruhoh.setup is now broken out into modular setup routines.",
7
+ "Themes now port over ALL static assets to production when compiling. Change from whitelist to blacklist."
8
+ ],
9
+ "features" : [
10
+ "Add support for base_path which allows all urls to be prepended with a base_path if set.",
11
+ "Support for absolute links to third party domains for javascript and stylesheets within theme.yml",
12
+ "Add urls.theme variable to the payload",
13
+ "Add ?to_json contextual helper"
14
+ ],
15
+ "bugs" : [
16
+ "Themes now correctly port over assets to production when compiling"
17
+ ]
18
+ },
2
19
  {
3
20
  "version" : "1.0.0.alpha",
4
21
  "date" : "05.06.2012",
@@ -17,7 +17,11 @@ class Ruhoh
17
17
  exit
18
18
  } unless self.respond_to?(cmd)
19
19
 
20
- Ruhoh.setup unless ['help','blog','compile'].include?(cmd)
20
+ unless ['help','blog','compile'].include?(cmd)
21
+ Ruhoh.setup
22
+ Ruhoh.setup_paths
23
+ Ruhoh.setup_urls
24
+ end
21
25
 
22
26
  self.__send__(cmd)
23
27
  end
@@ -26,6 +26,7 @@ class Ruhoh
26
26
  def self.run(target, page)
27
27
  self.pages(target, page)
28
28
  self.media(target, page)
29
+ self.javascripts(target, page)
29
30
  end
30
31
 
31
32
  def self.pages(target, page)
@@ -43,11 +44,28 @@ class Ruhoh
43
44
 
44
45
  def self.media(target, page)
45
46
  return unless FileTest.directory? Ruhoh.paths.media
46
- media = Ruhoh::Utils.url_to_path(Ruhoh.urls.media, target)
47
+ url = Ruhoh.urls.media.gsub(/^\//, '')
48
+ media = Ruhoh::Utils.url_to_path(url, target)
47
49
  FileUtils.mkdir_p media
48
50
  FileUtils.cp_r File.join(Ruhoh.paths.media, '.'), media
49
51
  end
50
52
 
53
+ # Create all the javascripts.
54
+ # Javascripts may be registered from either a theme or a widget.
55
+ # Technically the theme compiler may create javascripts relative to the theme.
56
+ # This ensures the widget javascripts are created as well.
57
+ def self.javascripts(target, page)
58
+ Ruhoh::DB.javascripts.each do |type, assets|
59
+ assets.each do |asset|
60
+ url = asset['url'].gsub(/^\//, '')
61
+ next unless File.exist?(asset['id'])
62
+ file_path = Ruhoh::Utils.url_to_path(File.dirname(url), target)
63
+ FileUtils.mkdir_p file_path
64
+ FileUtils.cp(asset['id'], file_path)
65
+ end
66
+ end
67
+ end
68
+
51
69
  end #Defaults
52
70
 
53
71
  end #Compiler
@@ -10,13 +10,16 @@ class Ruhoh
10
10
  # render the content to save to disk. This will be a problem when
11
11
  # posts numbers expand. Merge this in later.
12
12
  def self.run(target, page)
13
+ num_posts = Ruhoh.config.rss_limit
14
+ posts = Ruhoh::DB.posts['chronological'].first(num_posts)
15
+
13
16
  feed = Nokogiri::XML::Builder.new do |xml|
14
17
  xml.rss(:version => '2.0') {
15
18
  xml.channel {
16
19
  xml.title_ Ruhoh::DB.site['title']
17
20
  xml.link_ Ruhoh::DB.site['config']['production_url']
18
- xml.pubDate_ Time.now
19
- Ruhoh::DB.posts['chronological'].each do |post_id|
21
+ xml.pubDate_ Time.now
22
+ posts.each do |post_id|
20
23
  post = Ruhoh::DB.posts['dictionary'][post_id]
21
24
  page.change(post_id)
22
25
  xml.item {
@@ -3,39 +3,44 @@ class Ruhoh
3
3
  module Theme
4
4
 
5
5
  def self.run(target, page)
6
- self.stylesheets(target, page)
7
- self.javascripts(target, page)
8
- self.media(target, page)
9
- end
10
-
11
- def self.stylesheets(target, page)
12
- Ruhoh::DB.stylesheets.each do |type, assets|
13
- assets.each do |asset|
14
- next unless File.exist?(asset['id'])
15
- file_path = Ruhoh::Utils.url_to_path(File.dirname(asset['url']), target)
16
- FileUtils.mkdir_p file_path
17
- FileUtils.cp(asset['id'], file_path)
18
- end
19
- end
6
+ self.copy(target, page)
20
7
  end
21
8
 
22
- def self.javascripts(target, page)
23
- Ruhoh::DB.javascripts.each do |type, assets|
24
- assets.each do |asset|
25
- next unless File.exist?(asset['id'])
26
- file_path = Ruhoh::Utils.url_to_path(File.dirname(asset['url']), target)
27
- FileUtils.mkdir_p file_path
28
- FileUtils.cp(asset['id'], file_path)
29
- end
9
+ # Copies all theme assets over to the compiled site.
10
+ # Note the compiled assets are namespaced at /assets/<theme-name>/
11
+ # theme.yml may specify exclusion rules for excluding assets.
12
+ def self.copy(target, page)
13
+ url = Ruhoh.urls.theme.gsub(/^\//, '')
14
+ theme = Ruhoh::Utils.url_to_path(url, target)
15
+ FileUtils.mkdir_p theme
16
+
17
+ self.files.each do |file|
18
+ original_file = File.join(Ruhoh.paths.theme, file)
19
+ compiled_file = File.join(theme, file)
20
+ FileUtils.mkdir_p File.dirname(compiled_file)
21
+ FileUtils.cp_r original_file, compiled_file
30
22
  end
31
23
  end
32
24
 
33
- def self.media(target, page)
34
- return unless FileTest.directory? Ruhoh.paths.theme_media
35
- theme_media = Ruhoh::Utils.url_to_path(Ruhoh.urls.theme_media, target)
36
- FileUtils.mkdir_p theme_media
37
- FileUtils.cp_r File.join(Ruhoh.paths.theme_media, '.'), theme_media
25
+ # Returns list of all files from the theme that need to be
26
+ # compiled to the production environment.
27
+ # Returns Array of relative filepaths
28
+ def self.files
29
+ FileUtils.cd(Ruhoh.paths.theme) {
30
+ return Dir["**/*"].select { |filepath|
31
+ next unless self.is_valid_asset?(filepath)
32
+ true
33
+ }
34
+ }
38
35
  end
36
+
37
+ # Checks a given asset filepath against any user-defined exclusion rules in theme.yml
38
+ def self.is_valid_asset?(filepath)
39
+ return false if FileTest.directory?(filepath)
40
+ Ruhoh::DB.theme_config["exclude"].each {|regex| return false if filepath =~ regex }
41
+ true
42
+ end
43
+
39
44
  end #Theme
40
45
  end #Compiler
41
46
  end #Ruhoh
data/lib/ruhoh/config.rb CHANGED
@@ -9,7 +9,9 @@ class Ruhoh
9
9
  :posts_exclude,
10
10
  :posts_layout,
11
11
  :posts_permalink,
12
- :theme
12
+ :rss_limit,
13
+ :theme,
14
+ :base_path
13
15
  )
14
16
 
15
17
  def self.generate(path_to_config)
@@ -27,8 +29,18 @@ class Ruhoh
27
29
 
28
30
  config = Config.new
29
31
  config.theme = theme
32
+
30
33
  config.env = site_config['env'] || nil
34
+
35
+ config.base_path = '/'
36
+ if site_config['base_path']
37
+ config.base_path = site_config['base_path'].to_s
38
+ config.base_path += "/" unless config.base_path[-1] == '/'
39
+ end
31
40
 
41
+ config.rss_limit = site_config['rss']['limit'] rescue nil
42
+ config.rss_limit = 20 if config.rss_limit.nil?
43
+
32
44
  config.posts_permalink = site_config['posts']['permalink'] rescue nil
33
45
  config.posts_layout = site_config['posts']['layout'] rescue nil
34
46
  config.posts_layout = 'post' if config.posts_layout.nil?
data/lib/ruhoh/db.rb CHANGED
@@ -4,6 +4,7 @@ require 'ruhoh/parsers/routes'
4
4
  require 'ruhoh/parsers/layouts'
5
5
  require 'ruhoh/parsers/partials'
6
6
  require 'ruhoh/parsers/widgets'
7
+ require 'ruhoh/parsers/theme_config'
7
8
  require 'ruhoh/parsers/stylesheets'
8
9
  require 'ruhoh/parsers/javascripts'
9
10
  require 'ruhoh/parsers/payload'
@@ -12,7 +13,7 @@ require 'ruhoh/parsers/site'
12
13
  class Ruhoh
13
14
  # Public: Database class for interacting with "data" in Ruhoh.
14
15
  class DB
15
- WhiteList = [:site, :posts, :pages, :routes, :layouts, :partials, :widgets, :stylesheets, :javascripts, :payload]
16
+ WhiteList = [:site, :posts, :pages, :routes, :layouts, :partials, :widgets, :theme_config, :stylesheets, :javascripts, :payload]
16
17
 
17
18
  class << self
18
19
  self.__send__ :attr_reader, *WhiteList
@@ -34,6 +35,8 @@ class Ruhoh
34
35
  Ruhoh::Parsers::Partials.generate
35
36
  when :widgets
36
37
  Ruhoh::Parsers::Widgets.generate
38
+ when :theme_config
39
+ Ruhoh::Parsers::ThemeConfig.generate
37
40
  when :stylesheets
38
41
  Ruhoh::Parsers::Stylesheets.generate
39
42
  when :javascripts
data/lib/ruhoh/page.rb CHANGED
@@ -86,7 +86,7 @@ class Ruhoh
86
86
  self.ensure_id
87
87
  path = CGI.unescape(@data['url']).gsub(/^\//, '') #strip leading slash.
88
88
  path = "index.html" if path.empty?
89
- path += '/index.html' unless path =~ /\.\w+$/
89
+ path += 'index.html' unless path =~ /\.\w+$/
90
90
  path
91
91
  end
92
92
 
@@ -8,20 +8,20 @@ class Ruhoh
8
8
  # Generates mappings to all registered javascripts.
9
9
  # Returns Hash with layout names as keys and Array of asset Objects as values
10
10
  def self.generate
11
- theme_config = self.theme_config
12
- assets = self.theme_javascripts(theme_config)
13
- assets[Ruhoh.names.widgets] = self.widget_javascripts(theme_config)
11
+ assets = self.theme_javascripts
12
+ assets[Ruhoh.names.widgets] = self.widget_javascripts
14
13
  assets
15
14
  end
16
15
 
17
- def self.theme_javascripts(theme_config)
18
- return {} unless theme_config[Ruhoh.names.javascripts].is_a? Hash
16
+ def self.theme_javascripts
17
+ return {} unless Ruhoh::DB.theme_config[Ruhoh.names.javascripts].is_a? Hash
19
18
  assets = {}
20
- theme_config[Ruhoh.names.javascripts].each do |key, value|
19
+ Ruhoh::DB.theme_config[Ruhoh.names.javascripts].each do |key, value|
21
20
  next if key == Ruhoh.names.widgets # Widgets are handled separately.
22
21
  assets[key] = Array(value).map { |v|
22
+ url = (v =~ /^(http:|https:)?\/\//i) ? v : "#{Ruhoh.urls.theme_javascripts}/#{v}"
23
23
  {
24
- "url" => "#{Ruhoh.urls.theme_javascripts}/#{v}",
24
+ "url" => url,
25
25
  "id" => File.join(Ruhoh.paths.theme_javascripts, v)
26
26
  }
27
27
  }
@@ -35,7 +35,7 @@ class Ruhoh
35
35
  # This differs from the auto-stylesheet inclusion relative to themes,
36
36
  # which is handled in the stylesheet parser.
37
37
  # Make sure there are some standards with this.
38
- def self.widget_javascripts(theme_config)
38
+ def self.widget_javascripts
39
39
  assets = []
40
40
  Ruhoh::DB.widgets.each_value do |widget|
41
41
  next unless widget[Ruhoh.names.javascripts]
@@ -50,18 +50,6 @@ class Ruhoh
50
50
  assets
51
51
  end
52
52
 
53
- def self.theme_config
54
- theme_config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.theme_config_data)
55
- if theme_config.nil?
56
- Ruhoh::Friend.say{
57
- yellow "WARNING: theme.yml config file not found:"
58
- yellow " #{Ruhoh.paths.theme_config_data}"
59
- }
60
- return {}
61
- end
62
- return {} unless theme_config.is_a? Hash
63
- theme_config
64
- end
65
53
  end #Javascripts
66
54
  end #Parsers
67
55
  end #Ruhoh
@@ -65,10 +65,12 @@ class Ruhoh
65
65
  name = page['id'].gsub(Regexp.new("#{ext}$"), '')
66
66
  ext = '.html' if Ruhoh::Converter.extensions.include?(ext)
67
67
  url = name.split('/').map {|p| Ruhoh::Urls.to_url_slug(p) }.join('/')
68
- url = "/#{url}#{ext}".gsub(/\/index.html$/, '')
68
+ url = "#{url}#{ext}".gsub(/index.html$/, '')
69
69
  if page['permalink'] == 'pretty' || Ruhoh.config.pages_permalink == 'pretty'
70
- url = url.gsub(/\.html$/, '')
70
+ url = url.gsub(/\.html$/, '/')
71
71
  end
72
+
73
+ url = "#{Ruhoh.config.base_path}#{url}"
72
74
  url = '/' if url.empty?
73
75
 
74
76
  url
@@ -11,10 +11,12 @@ class Ruhoh
11
11
  "site" => Ruhoh::DB.site,
12
12
  'page' => {},
13
13
  "urls" => {
14
+ "theme" => Ruhoh.urls.theme,
14
15
  "theme_stylesheets" => Ruhoh.urls.theme_stylesheets,
15
16
  "theme_javascripts" => Ruhoh.urls.theme_javascripts,
16
17
  "theme_media" => Ruhoh.urls.theme_media,
17
18
  "media" => Ruhoh.urls.media,
19
+ "base_path" => Ruhoh.config.base_path,
18
20
  }
19
21
  }
20
22
  end
@@ -24,7 +26,7 @@ class Ruhoh
24
26
  def self.determine_category_and_tag_urls
25
27
  return nil unless Ruhoh::DB.routes && Ruhoh::DB.posts
26
28
  categories_url = nil
27
- ['/categories', '/categories.html'].each { |url|
29
+ ["#{Ruhoh.config.base_path}categories/", "#{Ruhoh.config.base_path}categories.html"].each { |url|
28
30
  categories_url = url and break if Ruhoh::DB.routes.key?(url)
29
31
  }
30
32
  Ruhoh::DB.posts['categories'].each do |key, value|
@@ -32,7 +34,7 @@ class Ruhoh
32
34
  end
33
35
 
34
36
  tags_url = nil
35
- ['/tags', '/tags.html'].each { |url|
37
+ ["#{Ruhoh.config.base_path}tags/", "#{Ruhoh.config.base_path}tags.html"].each { |url|
36
38
  tags_url = url and break if Ruhoh::DB.routes.key?(url)
37
39
  }
38
40
  Ruhoh::DB.posts['tags'].each do |key, value|
@@ -138,11 +138,11 @@ class Ruhoh
138
138
  date = Date.parse(post['date'])
139
139
  title = Ruhoh::Urls.to_url_slug(post['title'])
140
140
  format = post['permalink'] || Ruhoh.config.posts_permalink || "/:categories/:year/:month/:day/:title.html"
141
-
141
+
142
142
  # Use the literal permalink if it is a non-tokenized string.
143
143
  unless format.include?(':')
144
144
  url = format.gsub(/^\//, '').split('/').map {|p| CGI::escape(p) }.join('/')
145
- return "/#{url}"
145
+ return "#{Ruhoh.config.base_path}#{url}"
146
146
  end
147
147
 
148
148
  filename = File.basename(post['id'], File.extname(post['id']))
@@ -162,6 +162,8 @@ class Ruhoh
162
162
  result.gsub(/:#{Regexp.escape token.first}/, token.last)
163
163
  }.gsub(/\/+/, "/")
164
164
 
165
+ url = url.gsub(/^\//, '') #prep for prepending the base_path
166
+ url = "#{Ruhoh.config.base_path}#{url}"
165
167
  url
166
168
  end
167
169
 
@@ -10,23 +10,23 @@ class Ruhoh
10
10
  # Generates mappings to all registered stylesheets.
11
11
  # Returns Hash with layout names as keys and Array of asset Objects as values
12
12
  def self.generate
13
- theme_config = self.theme_config
14
- assets = self.theme_stylesheets(theme_config)
15
- assets[Ruhoh.names.widgets] = self.widget_stylesheets(theme_config)
13
+ assets = self.theme_stylesheets
14
+ assets[Ruhoh.names.widgets] = self.widget_stylesheets
16
15
  assets
17
16
  end
18
17
 
19
18
  # Create mappings for stylesheets registered to the theme layouts.
20
19
  # Themes register stylesheets relative to their layouts.
21
20
  # Returns Hash with layout names as keys and Array of asset Objects as values.
22
- def self.theme_stylesheets(theme_config)
23
- return {} unless theme_config[Ruhoh.names.stylesheets].is_a? Hash
21
+ def self.theme_stylesheets
22
+ return {} unless Ruhoh::DB.theme_config[Ruhoh.names.stylesheets].is_a? Hash
24
23
  assets = {}
25
- theme_config[Ruhoh.names.stylesheets].each do |key, value|
24
+ Ruhoh::DB.theme_config[Ruhoh.names.stylesheets].each do |key, value|
26
25
  next if key == Ruhoh.names.widgets # Widgets are handled separately.
27
26
  assets[key] = Array(value).map { |v|
27
+ url = (v =~ /^(http:|https:)?\/\//i) ? v : "#{Ruhoh.urls.theme_stylesheets}/#{v}"
28
28
  {
29
- "url" => "#{Ruhoh.urls.theme_stylesheets}/#{v}",
29
+ "url" => url,
30
30
  "id" => File.join(Ruhoh.paths.theme_stylesheets, v)
31
31
  }
32
32
  }
@@ -41,11 +41,11 @@ class Ruhoh
41
41
  # Themes may also specify an explicit widget stylesheet to load.
42
42
  #
43
43
  # Returns Array of asset objects.
44
- def self.widget_stylesheets(theme_config)
44
+ def self.widget_stylesheets
45
45
  assets = []
46
46
  Ruhoh::DB.widgets.each_key do |name|
47
47
  default_name = "#{name}.css"
48
- stylesheet = theme_config[Ruhoh.names.stylesheets][Ruhoh.names.widgets][name] rescue default_name
48
+ stylesheet = Ruhoh::DB.theme_config[Ruhoh.names.stylesheets][Ruhoh.names.widgets][name] rescue default_name
49
49
  stylesheet ||= default_name
50
50
  file = File.join(Ruhoh.paths.theme_widgets, name, Ruhoh.names.stylesheets, stylesheet)
51
51
  next unless File.exists?(file)
@@ -58,18 +58,6 @@ class Ruhoh
58
58
  assets
59
59
  end
60
60
 
61
- def self.theme_config
62
- theme_config = Ruhoh::Utils.parse_yaml_file(Ruhoh.paths.theme_config_data)
63
- if theme_config.nil?
64
- Ruhoh::Friend.say{
65
- yellow "WARNING: theme.yml config file not found:"
66
- yellow " #{Ruhoh.paths.theme_config_data}"
67
- }
68
- return {}
69
- end
70
- return {} unless theme_config.is_a? Hash
71
- theme_config
72
- end
73
61
  end #Stylesheets
74
62
  end #Parsers
75
63
  end #Ruhoh
@@ -0,0 +1,30 @@
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
data/lib/ruhoh/paths.rb CHANGED
@@ -32,22 +32,22 @@ class Ruhoh
32
32
  :system_widgets
33
33
  )
34
34
 
35
- def self.generate(config, base)
35
+ def self.generate
36
36
  paths = Paths.new
37
- paths.base = base
38
- paths.config_data = File.join(base, Ruhoh.names.config_data)
39
- paths.pages = File.join(base, Ruhoh.names.pages)
40
- paths.posts = File.join(base, Ruhoh.names.posts)
41
- paths.partials = File.join(base, Ruhoh.names.partials)
42
- paths.media = File.join(base, Ruhoh.names.media)
43
- paths.widgets = File.join(base, Ruhoh.names.widgets)
44
- paths.compiled = File.join(base, Ruhoh.names.compiled)
45
- paths.dashboard_file = File.join(base, Ruhoh.names.dashboard_file)
46
- paths.site_data = File.join(base, Ruhoh.names.site_data)
47
- paths.themes = File.join(base, Ruhoh.names.themes)
48
- paths.plugins = File.join(base, Ruhoh.names.plugins)
37
+ paths.base = Ruhoh.base
38
+ paths.config_data = File.join(Ruhoh.base, Ruhoh.names.config_data)
39
+ paths.pages = File.join(Ruhoh.base, Ruhoh.names.pages)
40
+ paths.posts = File.join(Ruhoh.base, Ruhoh.names.posts)
41
+ paths.partials = File.join(Ruhoh.base, Ruhoh.names.partials)
42
+ paths.media = File.join(Ruhoh.base, Ruhoh.names.media)
43
+ paths.widgets = File.join(Ruhoh.base, Ruhoh.names.widgets)
44
+ paths.compiled = File.join(Ruhoh.base, Ruhoh.names.compiled)
45
+ paths.dashboard_file = File.join(Ruhoh.base, Ruhoh.names.dashboard_file)
46
+ paths.site_data = File.join(Ruhoh.base, Ruhoh.names.site_data)
47
+ paths.themes = File.join(Ruhoh.base, Ruhoh.names.themes)
48
+ paths.plugins = File.join(Ruhoh.base, Ruhoh.names.plugins)
49
49
 
50
- paths.theme = File.join(base, Ruhoh.names.themes, config.theme)
50
+ paths.theme = File.join(Ruhoh.base, Ruhoh.names.themes, Ruhoh.config.theme)
51
51
  paths.theme_dashboard_file= File.join(paths.theme, Ruhoh.names.dashboard_file)
52
52
  paths.theme_config_data = File.join(paths.theme, Ruhoh.names.theme_config)
53
53
  paths.theme_layouts = File.join(paths.theme, Ruhoh.names.layouts)
@@ -14,7 +14,8 @@ class Ruhoh
14
14
 
15
15
  def call(env)
16
16
  return favicon if env['PATH_INFO'] == '/favicon.ico'
17
- return admin if [Ruhoh.urls.dashboard, "#{Ruhoh.urls.dashboard}/"].include?(env['PATH_INFO'])
17
+ env['PATH_INFO'] += "/" unless (env['PATH_INFO'] =~ /\.\w+$/ || env['PATH_INFO'][-1] == "/")
18
+ return admin if env['PATH_INFO'] == "#{Ruhoh.urls.dashboard}/"
18
19
 
19
20
  id = Ruhoh::DB.routes[env['PATH_INFO']]
20
21
  raise "Page id not found for url: #{env['PATH_INFO']}" unless id
data/lib/ruhoh/program.rb CHANGED
@@ -18,7 +18,12 @@ class Ruhoh
18
18
 
19
19
  Ruhoh.setup
20
20
  Ruhoh.config.env = opts[:env]
21
+ Ruhoh.setup_paths
22
+ Ruhoh.setup_urls
23
+ Ruhoh.setup_plugins unless opts[:enable_plugins] == false
24
+
21
25
  Ruhoh::DB.update_all
26
+
22
27
  Ruhoh::Watch.start if opts[:watch]
23
28
  Rack::Builder.new {
24
29
  use Rack::Lint
@@ -51,6 +56,10 @@ class Ruhoh
51
56
  def self.compile(target)
52
57
  Ruhoh.setup
53
58
  Ruhoh.config.env = 'production'
59
+ Ruhoh.setup_paths
60
+ Ruhoh.setup_urls
61
+ Ruhoh.setup_plugins
62
+
54
63
  Ruhoh::DB.update_all
55
64
  Ruhoh::Compiler.compile(target)
56
65
  end
@@ -126,6 +126,10 @@ class Ruhoh
126
126
  return unless prev_id
127
127
  self.to_posts(prev_id)
128
128
  end
129
+
130
+ def to_json(sub_context)
131
+ sub_context.to_json
132
+ end
129
133
 
130
134
  # Marks the active page if exists in the given pages Array
131
135
  def mark_active_page(pages)
data/lib/ruhoh/urls.rb CHANGED
@@ -14,22 +14,22 @@ class Ruhoh
14
14
  :theme_widgets
15
15
  )
16
16
 
17
- def self.generate(config)
17
+ def self.generate
18
18
  urls = Urls.new
19
19
  urls.media = self.to_url(Ruhoh.names.assets, Ruhoh.names.media)
20
20
  urls.widgets = self.to_url(Ruhoh.names.assets, Ruhoh.names.widgets)
21
21
  urls.dashboard = self.to_url(Ruhoh.names.dashboard_file.split('.')[0])
22
22
 
23
- urls.theme = self.to_url(Ruhoh.names.assets, config.theme)
24
- urls.theme_media = self.to_url(Ruhoh.names.assets, config.theme, Ruhoh.names.media)
25
- urls.theme_javascripts = self.to_url(Ruhoh.names.assets, config.theme, Ruhoh.names.javascripts)
26
- urls.theme_stylesheets = self.to_url(Ruhoh.names.assets, config.theme, Ruhoh.names.stylesheets)
27
- urls.theme_widgets = self.to_url(Ruhoh.names.assets, config.theme, Ruhoh.names.widgets)
23
+ urls.theme = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme)
24
+ urls.theme_media = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.media)
25
+ urls.theme_javascripts = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.javascripts)
26
+ urls.theme_stylesheets = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.stylesheets)
27
+ urls.theme_widgets = self.to_url(Ruhoh.names.assets, Ruhoh.config.theme, Ruhoh.names.widgets)
28
28
  urls
29
29
  end
30
-
30
+
31
31
  def self.to_url(*args)
32
- args.unshift(nil).join('/')
32
+ Ruhoh.config.base_path + args.join('/')
33
33
  end
34
34
 
35
35
  def self.to_url_slug(title)
data/lib/ruhoh/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  class Ruhoh
2
- Version = VERSION = '1.0.0.alpha'
2
+ Version = VERSION = '1.0'
3
3
  RuhohSpec = '1.0'
4
4
  end
data/lib/ruhoh.rb CHANGED
@@ -30,7 +30,7 @@ class Ruhoh
30
30
 
31
31
  class << self
32
32
  attr_accessor :log
33
- attr_reader :config, :names, :paths, :root, :urls
33
+ attr_reader :config, :names, :paths, :root, :urls, :base
34
34
  end
35
35
 
36
36
  @log = Ruhoh::Logger.new
@@ -63,28 +63,49 @@ class Ruhoh
63
63
  self.reset
64
64
  @log.log_file = opts[:log_file] if opts[:log_file]
65
65
  @base = opts[:source] if opts[:source]
66
-
67
- @config = Ruhoh::Config.generate(@names.config_data)
68
- @paths = Ruhoh::Paths.generate(@config, @base)
69
- @urls = Ruhoh::Urls.generate(@config)
70
-
71
- return false unless(@config && @paths && @urls)
72
-
73
- self.setup_plugins unless opts[:enable_plugins] == false
74
- true
66
+ @config = Ruhoh::Config.generate(@names.config_data)
67
+ !!@config
75
68
  end
76
69
 
77
70
  def self.reset
78
71
  @base = Dir.getwd
79
72
  end
80
73
 
74
+ def self.setup_paths
75
+ self.ensure_config
76
+ @paths = Ruhoh::Paths.generate
77
+ end
78
+
79
+ def self.setup_urls
80
+ self.ensure_config
81
+ @urls = Ruhoh::Urls.generate
82
+ end
83
+
81
84
  def self.setup_plugins
85
+ self.ensure_paths
82
86
  plugins = Dir[File.join(self.paths.plugins, "**/*.rb")]
83
87
  plugins.each {|f| require f } unless plugins.empty?
84
88
  end
85
89
 
86
90
  def self.ensure_setup
87
- raise 'Ruhoh has not been setup. Please call: Ruhoh.setup' unless Ruhoh.config && Ruhoh.paths
91
+ return if Ruhoh.config && Ruhoh.paths && Ruhoh.urls
92
+ raise 'Ruhoh has not been fully setup. Please call: Ruhoh.setup'
93
+ end
94
+
95
+ def self.ensure_config
96
+ return if Ruhoh.config
97
+ raise 'Ruhoh has not setup config. Please call: Ruhoh.setup'
98
+ end
99
+
100
+ def self.ensure_paths
101
+ return if Ruhoh.config && Ruhoh.paths
102
+ raise 'Ruhoh has not setup paths. Please call: Ruhoh.setup'
88
103
  end
89
104
 
105
+ def self.ensure_urls
106
+ return if Ruhoh.config && Ruhoh.urls
107
+ raise 'Ruhoh has not setup urls. Please call: Ruhoh.setup + Ruhoh.setup_urls'
108
+ end
109
+
110
+
90
111
  end # Ruhoh
data/ruhoh.gemspec CHANGED
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
52
52
  lib/ruhoh/parsers/routes.rb
53
53
  lib/ruhoh/parsers/site.rb
54
54
  lib/ruhoh/parsers/stylesheets.rb
55
+ lib/ruhoh/parsers/theme_config.rb
55
56
  lib/ruhoh/parsers/widgets.rb
56
57
  lib/ruhoh/paths.rb
57
58
  lib/ruhoh/previewer.rb
@@ -3,6 +3,7 @@ disqus :
3
3
  short_name : jekyllbootstrap # Change This!
4
4
  livefyre :
5
5
  site_id : 123
6
+ site_name:
6
7
  intensedebate :
7
8
  account : 123abc
8
9
  facebook :
@@ -3,7 +3,7 @@
3
3
  var js, fjs = d.getElementsByTagName(s)[0];
4
4
  if (d.getElementById(id)) return;
5
5
  js = d.createElement(s); js.id = id;
6
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={{ site.config.comments.facebook.appid }}";
6
+ js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId={{ site.config.facebook.appid }}";
7
7
  fjs.parentNode.insertBefore(js, fjs);
8
8
  }(document, 'script', 'facebook-jssdk'));</script>
9
- <div class="fb-comments" data-href="{{ site.production_url }}" data-num-posts="{{ config.comments.facebook.num_posts }}" data-width="{{ config.comments.facebook.width }}" data-colorscheme="{{ config.comments.facebook.colorscheme }}"></div>
9
+ <div class="fb-comments" data-href="{{ site.production_url }}" data-num-posts="{{ config.facebook.num_posts }}" data-width="{{ config.facebook.width }}" data-colorscheme="{{ config.facebook.colorscheme }}"></div>
@@ -1,5 +1,5 @@
1
1
  <script>
2
- var idcomments_acct = '{{ config.comments.intensedebate.account }}';
2
+ var idcomments_acct = '{{ config.intensedebate.account }}';
3
3
  var idcomments_post_id;
4
4
  var idcomments_post_url;
5
5
  </script>
@@ -1,6 +1,6 @@
1
1
  <script type='text/javascript' src='http://zor.livefyre.com/wjs/v1.0/javascripts/livefyre_init.js'></script>
2
2
  <script type='text/javascript'>
3
3
  var fyre = LF({
4
- site_id: {{ config.comments.livefyre.site_id }}
4
+ site_id: {{ config.livefyre.site_id }}
5
5
  });
6
6
  </script>
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruhoh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.alpha
5
- prerelease: 6
4
+ version: '1.0'
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jade Dominguez
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-05 00:00:00.000000000 Z
12
+ date: 2012-08-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
- requirement: &70293021804840 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '1.4'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70293021804840
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.4'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: mustache
27
- requirement: &70293021804340 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0.99'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70293021804340
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '0.99'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: directory_watcher
38
- requirement: &70293021803880 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '1.4'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70293021803880
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: redcarpet
49
- requirement: &70293021803420 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '2.1'
55
70
  type: :runtime
56
71
  prerelease: false
57
- version_requirements: *70293021803420
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '2.1'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: psych
60
- requirement: &70293021802960 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '1.3'
66
86
  type: :runtime
67
87
  prerelease: false
68
- version_requirements: *70293021802960
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.3'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: nokogiri
71
- requirement: &70293021802500 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '1.5'
77
102
  type: :runtime
78
103
  prerelease: false
79
- version_requirements: *70293021802500
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '1.5'
80
110
  description: Ruhoh is a Universal API for your static blog.
81
111
  email: plusjade@gmail.com
82
112
  executables:
@@ -113,6 +143,7 @@ files:
113
143
  - lib/ruhoh/parsers/routes.rb
114
144
  - lib/ruhoh/parsers/site.rb
115
145
  - lib/ruhoh/parsers/stylesheets.rb
146
+ - lib/ruhoh/parsers/theme_config.rb
116
147
  - lib/ruhoh/parsers/widgets.rb
117
148
  - lib/ruhoh/paths.rb
118
149
  - lib/ruhoh/previewer.rb
@@ -175,12 +206,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
206
  required_rubygems_version: !ruby/object:Gem::Requirement
176
207
  none: false
177
208
  requirements:
178
- - - ! '>'
209
+ - - ! '>='
179
210
  - !ruby/object:Gem::Version
180
- version: 1.3.1
211
+ version: '0'
181
212
  requirements: []
182
213
  rubyforge_project:
183
- rubygems_version: 1.8.17
214
+ rubygems_version: 1.8.24
184
215
  signing_key:
185
216
  specification_version: 3
186
217
  summary: Ruby based library to process your Ruhoh static blog.