broadway 0.0.2 → 0.0.3
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.
- data/Rakefile +9 -4
- data/lib/broadway.rb +0 -1
- data/lib/broadway/base.rb +5 -9
- data/lib/broadway/convertible.rb +19 -11
- data/lib/broadway/page.rb +8 -2
- data/lib/broadway/post.rb +3 -3
- data/lib/broadway/rails.rb +3 -0
- data/lib/broadway/runner.rb +0 -3
- data/lib/broadway/sinatra.rb +5 -0
- data/lib/broadway/{main.rb → sinatra/base.rb} +3 -1
- data/lib/broadway/{helpers.rb → sinatra/helpers.rb} +2 -2
- data/lib/broadway/{helpers → sinatra/helpers}/collection_helper.rb +0 -0
- data/lib/broadway/{helpers → sinatra/helpers}/partial_helper.rb +0 -0
- data/lib/broadway/{helpers → sinatra/helpers}/text_helper.rb +1 -12
- data/lib/broadway/site.rb +5 -3
- metadata +12 -11
- data/lib/broadway/resource.rb +0 -5
data/Rakefile
CHANGED
@@ -14,12 +14,12 @@ RAILS_ROOT = File.dirname(__FILE__)
|
|
14
14
|
spec = Gem::Specification.new do |s|
|
15
15
|
s.name = "broadway"
|
16
16
|
s.author = "Lance Pollard"
|
17
|
-
s.version =
|
17
|
+
s.version = "0.0.3"
|
18
18
|
s.date = "Mon Mar 22 20:12:47 -0700 2010"
|
19
|
-
s.summary = "
|
19
|
+
s.summary = "Write Posts in Textile and Markdown, built it into a Rails or Sinatra Blog"
|
20
20
|
s.homepage = "http://github.com/viatropos/broadway"
|
21
21
|
s.email = "lancejpollard@gmail.com"
|
22
|
-
s.description = "Broadway:
|
22
|
+
s.description = "Broadway: Static and Dynamic Site Generator"
|
23
23
|
s.has_rdoc = true
|
24
24
|
s.rubyforge_project = "broadway"
|
25
25
|
s.platform = Gem::Platform::RUBY
|
@@ -54,13 +54,18 @@ task :manifest => :clean do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
+
desc "Publish gem to rubygems"
|
58
|
+
task :publish => [:package] do
|
59
|
+
%x[gem push pkg/#{spec.name}-#{spec.version}.gem]
|
60
|
+
end
|
61
|
+
|
57
62
|
Rake::GemPackageTask.new(spec) do |pkg|
|
58
63
|
pkg.gem_spec = spec
|
59
64
|
end
|
60
65
|
|
61
66
|
desc "Install the gem locally"
|
62
67
|
task :install => [:package] do
|
63
|
-
sh %{sudo gem install pkg
|
68
|
+
sh %{sudo gem install pkg/#{spec.name}-#{spec.version} --no-ri --no-rdoc}
|
64
69
|
end
|
65
70
|
|
66
71
|
desc "Generate the rdoc"
|
data/lib/broadway.rb
CHANGED
data/lib/broadway/base.rb
CHANGED
@@ -20,10 +20,6 @@ require "time"
|
|
20
20
|
require "yaml"
|
21
21
|
require "nokogiri"
|
22
22
|
require "cgi"
|
23
|
-
require "sinatra"
|
24
|
-
require "sinatra/base"
|
25
|
-
require "sinatra_more"
|
26
|
-
require "haml"
|
27
23
|
|
28
24
|
# stdlib
|
29
25
|
|
@@ -33,17 +29,15 @@ require "redcloth"
|
|
33
29
|
$:.push(File.dirname(__FILE__))
|
34
30
|
require "core_ext"
|
35
31
|
require "convertible"
|
36
|
-
require "resource"
|
37
32
|
require "site"
|
38
33
|
require "asset"
|
39
34
|
require "page"
|
40
35
|
require "post"
|
41
36
|
require "static_file"
|
42
37
|
require "runner"
|
43
|
-
require "helpers"
|
44
38
|
|
45
39
|
module Broadway
|
46
|
-
VERSION = "0.0.
|
40
|
+
VERSION = "0.0.3"
|
47
41
|
# Default options. Overriden by values in _config.yml or command-line opts.
|
48
42
|
# (Strings rather symbols used for compatability with YAML)
|
49
43
|
DEFAULTS = {
|
@@ -90,7 +84,7 @@ module Broadway
|
|
90
84
|
# Get configuration from <source>/_config.yml
|
91
85
|
config_file = File.join(source, "_config.yml")
|
92
86
|
begin
|
93
|
-
config = YAML.load_file(config_file)
|
87
|
+
config = YAML.load_file(config_file).recursive_symbolize_keys!
|
94
88
|
raise "Invalid configuration - #{config_file}" if !config.is_a?(Hash)
|
95
89
|
$stdout.puts "Configuration from #{config_file}"
|
96
90
|
rescue => err
|
@@ -100,7 +94,9 @@ module Broadway
|
|
100
94
|
end
|
101
95
|
|
102
96
|
# Merge DEFAULTS < _config.yml < override
|
103
|
-
Broadway::DEFAULTS.deep_merge(config).
|
97
|
+
config = Broadway::DEFAULTS.deep_merge(config).merge(override)
|
98
|
+
|
99
|
+
config
|
104
100
|
end
|
105
101
|
|
106
102
|
def self.build(options = {})
|
data/lib/broadway/convertible.rb
CHANGED
@@ -14,7 +14,22 @@ module Broadway
|
|
14
14
|
def to_s
|
15
15
|
self.content || ''
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
def read(attribute = nil)
|
19
|
+
self.content = IO.read(self.path)
|
20
|
+
if self.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
21
|
+
if attribute
|
22
|
+
output = YAML.load($1)[attribute] || ""
|
23
|
+
return output
|
24
|
+
end
|
25
|
+
self.content = self.content[($1.size + $2.size)..-1]
|
26
|
+
end
|
27
|
+
self.render(site.layouts, site.site_payload)
|
28
|
+
output = self.output
|
29
|
+
self.content = self.output = nil
|
30
|
+
output
|
31
|
+
end
|
32
|
+
|
18
33
|
# Read the YAML frontmatter
|
19
34
|
# +base+ is the String path to the dir containing the file
|
20
35
|
# +name+ is the String filename of the file
|
@@ -71,19 +86,12 @@ module Broadway
|
|
71
86
|
# render and transform content (this becomes the final content of the object)
|
72
87
|
payload["content_type"] = self.content_type
|
73
88
|
self.content = Liquid::Template.parse(self.content).render(payload, info)
|
74
|
-
|
89
|
+
|
90
|
+
# TODO FIX
|
91
|
+
# self.transform
|
75
92
|
|
76
93
|
# output keeps track of what will finally be written
|
77
94
|
self.output = self.content
|
78
|
-
|
79
|
-
# recursively render layouts
|
80
|
-
layout = layouts[self.data["layout"]]
|
81
|
-
while layout
|
82
|
-
payload = payload.deep_merge({"content" => self.output, "page" => layout.data})
|
83
|
-
self.output = Liquid::Template.parse(layout.content).render(payload, info)
|
84
|
-
|
85
|
-
layout = layouts[layout.data["layout"]]
|
86
|
-
end
|
87
95
|
end
|
88
96
|
end
|
89
97
|
end
|
data/lib/broadway/page.rb
CHANGED
@@ -19,16 +19,22 @@ module Broadway
|
|
19
19
|
self.path = options[:path] if options.has_key?(:path)
|
20
20
|
self.data = {}
|
21
21
|
self.dir = path =~ /\// ? File.dirname(path.gsub(/#{site.config[:source]}\/?/, "")).gsub(/^\//, "") : path
|
22
|
-
self.
|
22
|
+
base = self.dir == "." ? "" : File.basename(self.dir)
|
23
|
+
self.name = base
|
23
24
|
self.ext = File.extname(path)
|
24
25
|
self.basename = File.basename(path).split('.')[0..-2].first
|
25
26
|
|
26
27
|
self.categories ||= []
|
27
|
-
self.categories.concat
|
28
|
+
self.categories.concat base.split('/').reject { |x| x.empty? }
|
28
29
|
self.children ||= []
|
29
30
|
process(options) unless options.has_key?(:process) and options[:process] == false
|
30
31
|
end
|
31
32
|
|
33
|
+
def children
|
34
|
+
@children = site.find_pages_by_category(self.categories.last) + site.find_posts_by_category(self.categories.last)
|
35
|
+
@children.delete_if {|i| i.url == self.url}
|
36
|
+
end
|
37
|
+
|
32
38
|
# The UID for this post (useful in feeds)
|
33
39
|
# e.g. /2008/11/05/my-awesome-post
|
34
40
|
#
|
data/lib/broadway/post.rb
CHANGED
@@ -3,7 +3,6 @@ module Broadway
|
|
3
3
|
class Post
|
4
4
|
include Comparable
|
5
5
|
include Convertible
|
6
|
-
include Resource
|
7
6
|
|
8
7
|
SRC_MATCHER = /^(.+\/)*(?:(\d+-\d+-\d+)-)?(.*)(\.[^.]+)$/
|
9
8
|
URL_MATCHER = /^(.+\/)*(.*)$/
|
@@ -40,8 +39,9 @@ module Broadway
|
|
40
39
|
self.slug = slug
|
41
40
|
self.ext = ext
|
42
41
|
self.dir = options.has_key?(:dir) ? options[:dir] : File.dirname(path.gsub(/#{site.config[:source]}\/?/, ""))
|
43
|
-
|
44
|
-
self.
|
42
|
+
base = self.dir == "." ? "" : File.basename(self.dir)
|
43
|
+
self.name = base
|
44
|
+
self.categories = base.split('/').reject { |x| x.empty? }
|
45
45
|
|
46
46
|
process(options) unless options.has_key?(:process) and options[:process] == false
|
47
47
|
end
|
data/lib/broadway/runner.rb
CHANGED
@@ -36,9 +36,6 @@ module Broadway
|
|
36
36
|
FileUtils.mkdir_p(item_dir)
|
37
37
|
name = File.join(item_dir, "index.html").squeeze("/")
|
38
38
|
text = ""
|
39
|
-
# text << "---\n"
|
40
|
-
# text << "categories: #{item.categories.sort.join(" ")}\n"
|
41
|
-
# text << "---\n"
|
42
39
|
text << response.body
|
43
40
|
puts "Writing... #{name}"
|
44
41
|
File.open(name, "w") {|f| f.write(text) }
|
File without changes
|
File without changes
|
@@ -11,18 +11,7 @@ module Broadway
|
|
11
11
|
|
12
12
|
# read the post and parse it with Liquid
|
13
13
|
def read(post, attribute = nil)
|
14
|
-
post.
|
15
|
-
if post.content =~ /^(---\s*\n.*?\n?)^(---\s*$\n?)/m
|
16
|
-
if attribute
|
17
|
-
output = YAML.load($1)[attribute] || ""
|
18
|
-
return output
|
19
|
-
end
|
20
|
-
post.content = post.content[($1.size + $2.size)..-1]
|
21
|
-
end
|
22
|
-
post.render(site.layouts, site.site_payload)
|
23
|
-
output = post.output
|
24
|
-
post.content = post.output = nil
|
25
|
-
output
|
14
|
+
post.read(attribute)
|
26
15
|
end
|
27
16
|
|
28
17
|
def read_excerpt(post, max_length = nil)
|
data/lib/broadway/site.rb
CHANGED
@@ -16,7 +16,7 @@ module Broadway
|
|
16
16
|
merge_extra_config!(config)
|
17
17
|
|
18
18
|
config.recursive_symbolize_keys!
|
19
|
-
|
19
|
+
|
20
20
|
self.config = config.clone
|
21
21
|
|
22
22
|
self.source = config[:source]
|
@@ -33,10 +33,11 @@ module Broadway
|
|
33
33
|
|
34
34
|
def merge_extra_config!(config)
|
35
35
|
locale = File.join(config[:locales], "#{config[:language]}.yml")
|
36
|
-
|
36
|
+
|
37
37
|
config.merge!(YAML.load_file(locale)) if File.exists?(locale)
|
38
38
|
|
39
|
-
|
39
|
+
|
40
|
+
config_dir = File.join(config[:source], "config")
|
40
41
|
return unless File.exists?(config_dir)
|
41
42
|
Dir.glob("#{config_dir}/**/*").each do |file|
|
42
43
|
next if File.directory?(file)
|
@@ -189,6 +190,7 @@ module Broadway
|
|
189
190
|
def read_directories(dir = '')
|
190
191
|
base = File.join(self.source, dir).gsub(/\/$/, "")
|
191
192
|
lists = []
|
193
|
+
|
192
194
|
# RULES:
|
193
195
|
# Pages are only index.textile files, or static .html files (TODO)
|
194
196
|
# Posts are leaf nodes (name.textile files)
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Lance Pollard
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-22
|
17
|
+
date: 2010-03-22 20:12:47 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -57,7 +57,7 @@ dependencies:
|
|
57
57
|
version: 2.3.5
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id003
|
60
|
-
description: "Broadway:
|
60
|
+
description: "Broadway: Static and Dynamic Site Generator"
|
61
61
|
email: lancejpollard@gmail.com
|
62
62
|
executables: []
|
63
63
|
|
@@ -73,15 +73,16 @@ files:
|
|
73
73
|
- lib/broadway/base.rb
|
74
74
|
- lib/broadway/convertible.rb
|
75
75
|
- lib/broadway/core_ext.rb
|
76
|
-
- lib/broadway/helpers/collection_helper.rb
|
77
|
-
- lib/broadway/helpers/partial_helper.rb
|
78
|
-
- lib/broadway/helpers/text_helper.rb
|
79
|
-
- lib/broadway/helpers.rb
|
80
|
-
- lib/broadway/main.rb
|
81
76
|
- lib/broadway/page.rb
|
82
77
|
- lib/broadway/post.rb
|
83
|
-
- lib/broadway/
|
78
|
+
- lib/broadway/rails.rb
|
84
79
|
- lib/broadway/runner.rb
|
80
|
+
- lib/broadway/sinatra/base.rb
|
81
|
+
- lib/broadway/sinatra/helpers/collection_helper.rb
|
82
|
+
- lib/broadway/sinatra/helpers/partial_helper.rb
|
83
|
+
- lib/broadway/sinatra/helpers/text_helper.rb
|
84
|
+
- lib/broadway/sinatra/helpers.rb
|
85
|
+
- lib/broadway/sinatra.rb
|
85
86
|
- lib/broadway/site.rb
|
86
87
|
- lib/broadway/static_file.rb
|
87
88
|
- lib/broadway.rb
|
@@ -114,6 +115,6 @@ rubyforge_project: broadway
|
|
114
115
|
rubygems_version: 1.3.6
|
115
116
|
signing_key:
|
116
117
|
specification_version: 3
|
117
|
-
summary:
|
118
|
+
summary: Write Posts in Textile and Markdown, built it into a Rails or Sinatra Blog
|
118
119
|
test_files: []
|
119
120
|
|