kinbote 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/README.rdoc +8 -1
- data/TODO +3 -0
- data/bin/kinbote +1 -0
- data/kinbote.gemspec +8 -3
- data/lib/kinbote/attribute.rb +24 -14
- data/lib/kinbote/base.rb +1 -1
- data/lib/kinbote/kinfile.rb +4 -3
- data/lib/kinbote/page.rb +88 -43
- data/lib/kinbote/site.rb +46 -19
- data/lib/kinbote/value.rb +8 -7
- data/lib/sinatra/kinbote.rb +22 -3
- data/lib/sinatra/kinbote_helpers.rb +29 -10
- data/site/.kinbote/js/core.js +18 -0
- data/site/.kinbote/js/jquery.js +6240 -0
- data/site/.kinbote/sass/core.sass +116 -0
- data/site/.kinbote/sass/reset.sass +53 -0
- data/site/.kinbote/views/examples/header.haml +1 -1
- data/site/.kinbote/views/layout.haml +26 -9
- data/site/.kinbote/views/page.haml +1 -1
- data/site/.kinbote/views/pages.haml +57 -19
- data/site/.kinbote/views/site.haml +13 -2
- data/site/config.yml.sample +13 -0
- data/site/public/robots.txt +1 -1
- data/site/views/layout.haml +1 -1
- metadata +10 -5
- data/site/config/site.yml +0 -1
data/README.rdoc
CHANGED
@@ -6,10 +6,17 @@ Install the gem:
|
|
6
6
|
|
7
7
|
sudo gem install kinbote
|
8
8
|
|
9
|
-
Create a new kinbote project
|
9
|
+
Create a new kinbote project:
|
10
10
|
|
11
11
|
kinbote mysite
|
12
|
+
|
13
|
+
Edit your site configuration:
|
14
|
+
|
12
15
|
cd mysite
|
16
|
+
[edit config.yml]
|
17
|
+
|
18
|
+
Start the local server:
|
19
|
+
|
13
20
|
./kinbote-server
|
14
21
|
|
15
22
|
Open the local site in your browser at http://localhost:4567
|
data/TODO
ADDED
data/bin/kinbote
CHANGED
data/kinbote.gemspec
CHANGED
@@ -3,8 +3,8 @@ Gem::Specification.new do |s|
|
|
3
3
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
4
4
|
|
5
5
|
s.name = 'kinbote'
|
6
|
-
s.version = '0.0.
|
7
|
-
s.date = '2010-
|
6
|
+
s.version = '0.0.3'
|
7
|
+
s.date = '2010-08-03'
|
8
8
|
|
9
9
|
s.description = "Kinbote"
|
10
10
|
s.summary = "Kinbote"
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
LICENSE
|
19
19
|
README.rdoc
|
20
20
|
Rakefile
|
21
|
+
TODO
|
21
22
|
bin/kinbote
|
22
23
|
kinbote.gemspec
|
23
24
|
lib/kinbote.rb
|
@@ -31,6 +32,10 @@ Gem::Specification.new do |s|
|
|
31
32
|
lib/kinbote/value.rb
|
32
33
|
lib/sinatra/kinbote.rb
|
33
34
|
lib/sinatra/kinbote_helpers.rb
|
35
|
+
site/.kinbote/js/core.js
|
36
|
+
site/.kinbote/js/jquery.js
|
37
|
+
site/.kinbote/sass/core.sass
|
38
|
+
site/.kinbote/sass/reset.sass
|
34
39
|
site/.kinbote/views/attributes.haml
|
35
40
|
site/.kinbote/views/examples/header.haml
|
36
41
|
site/.kinbote/views/examples/home.haml
|
@@ -45,7 +50,7 @@ Gem::Specification.new do |s|
|
|
45
50
|
site/.kinbote/views/page.haml
|
46
51
|
site/.kinbote/views/pages.haml
|
47
52
|
site/.kinbote/views/site.haml
|
48
|
-
site/config
|
53
|
+
site/config.yml.sample
|
49
54
|
site/kinbote-server
|
50
55
|
site/public/favicon.ico
|
51
56
|
site/public/js/core.js
|
data/lib/kinbote/attribute.rb
CHANGED
@@ -2,13 +2,13 @@ module Kinbote
|
|
2
2
|
class Attribute
|
3
3
|
include Util
|
4
4
|
include Kinfile
|
5
|
-
|
5
|
+
|
6
|
+
attr_reader :name, :pages
|
6
7
|
|
7
|
-
def initialize(name, page, values
|
8
|
+
def initialize(name, page, values)
|
8
9
|
@name = name.to_s
|
9
10
|
@pages = []
|
10
11
|
@values = []
|
11
|
-
@global = global || self
|
12
12
|
add_page(page, values)
|
13
13
|
end
|
14
14
|
|
@@ -16,27 +16,37 @@ module Kinbote
|
|
16
16
|
@pages.delete_if{|p| p.slug == page.slug}
|
17
17
|
@pages << page
|
18
18
|
values.each do |v|
|
19
|
-
|
20
|
-
|
21
|
-
l_val = $site.find_value(v, self)
|
22
|
-
l_val ? l_val.add_page(page) : @values << Value.new(v, page, @global, g_val)
|
19
|
+
val = $site.find_value(v, self)
|
20
|
+
val ? val.add_page(page) : @values << Value.new(v, page, self)
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
26
|
-
def
|
27
|
-
|
28
|
-
|
24
|
+
def rem_page(page)
|
25
|
+
values_for(page).map{|value| value.rem_page(page)}
|
26
|
+
values_for(page).delete_if{|v| v.pages.size == 0}
|
29
27
|
@pages.delete_if{|p| p.slug == page.slug}
|
30
|
-
@global.values.delete_if{|v| v.pages.size == 0}
|
31
|
-
@values.delete_if{|v| v.pages.size == 0}
|
32
28
|
end
|
33
29
|
|
34
30
|
def values
|
35
|
-
@values.sort{|x, y| x.value <=> y.value
|
31
|
+
@values.sort!{|x, y| x.value <=> y.value}
|
32
|
+
@values
|
33
|
+
end
|
34
|
+
|
35
|
+
def values_for(page=nil)
|
36
|
+
return @values if !page
|
37
|
+
slug = (page.is_a?(String) ? page : page.slug)
|
38
|
+
vals = []
|
39
|
+
@values.each do |v|
|
40
|
+
vals << v if v.has_page?(slug)
|
41
|
+
end
|
42
|
+
vals.sort{|x, y| x.value <=> y.value}
|
36
43
|
end
|
37
44
|
|
45
|
+
def has_value?(v, page=nil)
|
46
|
+
values_for(page).map{|vv| vv.value}.include?(v)
|
47
|
+
end
|
48
|
+
|
38
49
|
def varname; varify(@name); end
|
39
|
-
def pages; @global == self ? @pages : @global.pages; end
|
40
50
|
def to_s; @name; end
|
41
51
|
|
42
52
|
end
|
data/lib/kinbote/base.rb
CHANGED
data/lib/kinbote/kinfile.rb
CHANGED
@@ -51,19 +51,20 @@ module Kinbote
|
|
51
51
|
|
52
52
|
private
|
53
53
|
|
54
|
-
def file_path(type, dir
|
54
|
+
def file_path(type, dir=nil)
|
55
55
|
if type == :css
|
56
56
|
if self.is_a?(Attribute)
|
57
57
|
return "#{$site.kinbote_path}/views/sass/attributes/#{@name}/#{!dir ? "_all.sass" : ""}"
|
58
58
|
elsif self.is_a?(Value)
|
59
59
|
return "#{$site.kinbote_path}/views/sass/attributes/#{@attribute}/#{!dir ? "#{@value}.sass" : ""}"
|
60
60
|
elsif self.is_a?(Page)
|
61
|
-
return "#{@directory}#{!dir ? "#{@slug}.sass" : ""}"
|
61
|
+
#return "#{@directory}#{!dir ? "#{@slug}.sass" : ""}"
|
62
|
+
return "#{$site.kinbote_path}/views/sass/pages/#{Time.now.strftime("%Y/%m/%d")}/#{!dir ? "/#{@slug}.sass" : ""}"
|
62
63
|
end
|
63
64
|
elsif type == :html
|
64
65
|
return @file if @file && !dir
|
65
66
|
return @directory if @directory && dir
|
66
|
-
return "#{$site.kinbote_path}/views/pages/#{Time.now.strftime("%Y/%m")}
|
67
|
+
return "#{$site.kinbote_path}/views/pages/#{Time.now.strftime("%Y/%m/%d")}#{!dir ? "/#{slugify(@title)}.haml" : ""}"
|
67
68
|
end
|
68
69
|
end
|
69
70
|
|
data/lib/kinbote/page.rb
CHANGED
@@ -13,7 +13,7 @@ module Kinbote
|
|
13
13
|
@file = file || file_path(:html)
|
14
14
|
@slug = slug_from_file(@file)
|
15
15
|
@attributes = []
|
16
|
-
add_attributes(attributes ||
|
16
|
+
add_attributes(attributes || new_page_attributes)
|
17
17
|
create_file(:html)
|
18
18
|
Page.add_metadata(self) if !file
|
19
19
|
set_ivars
|
@@ -21,11 +21,11 @@ module Kinbote
|
|
21
21
|
|
22
22
|
def set_attributes(attributes, values=nil)
|
23
23
|
attributes = kv_to_attributes(attributes, values) if values
|
24
|
-
new_title =
|
24
|
+
new_title = rem_title(attributes)
|
25
25
|
return if same_attributes(attributes, new_title)
|
26
26
|
@title = new_title if new_title && new_title.size > 0
|
27
|
-
$site.
|
28
|
-
@attributes.map{|att| att.
|
27
|
+
$site.rem_page_attributes(self)
|
28
|
+
@attributes.map{|att| att.rem_page(self)}
|
29
29
|
@attributes.delete_if{|att| att.pages.size == 0}
|
30
30
|
@attributes = []
|
31
31
|
add_attributes(attributes)
|
@@ -33,7 +33,43 @@ module Kinbote
|
|
33
33
|
set_ivars
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def add_attributes(attributes)
|
37
|
+
attributes.each do |name, values|
|
38
|
+
add_attribute(name, values)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def add_attribute(name, values)
|
43
|
+
if BAD_ATTRIBUTE_VARNAMES.include?(varify(name))
|
44
|
+
$site.add_message("#{name} is an invalid attribute name")
|
45
|
+
next
|
46
|
+
end
|
47
|
+
att = $site.find_attribute(name) || Attribute.new(name, self, values)
|
48
|
+
att.add_page(self, values)
|
49
|
+
$site.add_attribute(att)
|
50
|
+
@attributes << att if !@attributes.map{|a| a.name}.include?(name)
|
51
|
+
end
|
52
|
+
|
53
|
+
def rem_attribute(att_name)
|
54
|
+
@attributes.map{|att| att.rem_page(self) if att.name == att_name}
|
55
|
+
@attributes.delete_if{|att| att.name == att_name}
|
56
|
+
$site.attributes.delete_if{|att| att.pages.size == 0}
|
57
|
+
end
|
58
|
+
|
59
|
+
def rem_value(att_name, val)
|
60
|
+
att = $site.find_attribute(att_name, self)
|
61
|
+
return if !att
|
62
|
+
v = $site.find_value(val, att)
|
63
|
+
return if !v || !v.has_page?(@slug)
|
64
|
+
v.rem_page(self)
|
65
|
+
att.rem_page(self) if att.values_for(self).size == 0
|
66
|
+
att.values_for(self).delete_if{|vv| vv.pages.size == 0}
|
67
|
+
@attributes.delete_if{|aa| aa.pages.size == 0 || aa.values_for(self).size == 0}
|
68
|
+
att.values.delete_if{|vv| vv.pages.size == 0}
|
69
|
+
$site.attributes.delete_if{|aa| aa.pages.size == 0 || aa.values.size == 0}
|
70
|
+
end
|
71
|
+
|
72
|
+
def loosely_related_pages(attribute_names=nil)
|
37
73
|
page_matches = []
|
38
74
|
if !attribute_names
|
39
75
|
page_matches += loosely_related_pages(@attributes.map{|a| a.name})
|
@@ -45,7 +81,7 @@ module Kinbote
|
|
45
81
|
page_matches.uniq
|
46
82
|
end
|
47
83
|
|
48
|
-
def strongly_related_pages(attribute_names
|
84
|
+
def strongly_related_pages(attribute_names=nil, values=nil)
|
49
85
|
page_matches = []
|
50
86
|
if !attribute_names
|
51
87
|
page_matches += strongly_related_pages(@attributes.map{|a| a.name})
|
@@ -63,9 +99,16 @@ module Kinbote
|
|
63
99
|
|
64
100
|
def values
|
65
101
|
vals = []
|
66
|
-
attributes.each{ |a| a.
|
102
|
+
attributes.each{ |a| a.values_for(self).each{ |v| vals << v } }
|
67
103
|
vals
|
68
104
|
end
|
105
|
+
|
106
|
+
def filtered_by?(attribute=nil, value=nil)
|
107
|
+
return false if (!attribute || attribute.strip.size == 0) && (!value || value.strip.size == 0)
|
108
|
+
a = $site.find_attribute(attribute, self)
|
109
|
+
return true if !a
|
110
|
+
(!value || value.strip.size == 0 || ($site.find_value(value, a) && $site.find_value(value, a).has_page?(@slug))) ? false : true
|
111
|
+
end
|
69
112
|
|
70
113
|
def path
|
71
114
|
path = []
|
@@ -90,13 +133,15 @@ module Kinbote
|
|
90
133
|
if page
|
91
134
|
kinbote_haml(f_new, "page_attributes_title")
|
92
135
|
kinbote_haml(f_new, "page_attributes", ["Title: #{page.title}"] + page.values.map{|v| "#{v.attribute.name}: #{v.value}"})
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
136
|
+
if $site.print_sample_code?
|
137
|
+
kinbote_haml(f_new, "header")
|
138
|
+
kinbote_haml(f_new, "specific", page.attributes.map{|a| a.varname})
|
139
|
+
kinbote_haml(f_new, "related", page.attributes.map{|a| a.name.downcase == "date" ? nil : a.name}.compact)
|
140
|
+
kinbote_haml(f_new, "related2", page.attributes.map{|a| "#{a.name}\", \"#{a.values_for(page).first.value}"})
|
141
|
+
kinbote_haml(f_new, "related_any")
|
142
|
+
end
|
98
143
|
else
|
99
|
-
kinbote_haml(f_new, "home", $site.attributes.map{|a| a.varname})
|
144
|
+
kinbote_haml(f_new, "home", $site.attributes.map{|a| a.varname}) if $site.print_sample_code?
|
100
145
|
end
|
101
146
|
f_new.close
|
102
147
|
FileUtils.mv("#{fname}.haml.new", "#{fname}.haml")
|
@@ -109,28 +154,43 @@ module Kinbote
|
|
109
154
|
File.read("#{$site.kinbote_path}/.kinbote/views/examples/#{example_name}.haml").to_a.each do |line|
|
110
155
|
if replacements && line.include?("$ALL_VALS$")
|
111
156
|
replacements.each do |r|
|
112
|
-
f
|
157
|
+
kinwrite(f, line.gsub("$ALL_VALS$", r))
|
113
158
|
end
|
114
159
|
elsif replacements && line.include?("$ALL_VALS_COMMENTED$")
|
115
160
|
replacements.each_with_index do |r, i|
|
116
161
|
if i == replacements.size - 1
|
117
|
-
f
|
162
|
+
kinwrite(f, line.gsub("$ALL_VALS_COMMENTED$", r))
|
118
163
|
else
|
119
|
-
f
|
164
|
+
kinwrite(f, line.gsub("- ", "-# ").gsub("$ALL_VALS_COMMENTED$", r))
|
120
165
|
end
|
121
166
|
end
|
122
167
|
elsif replacements && line.include?("$FIRST_VAL$")
|
123
|
-
f
|
168
|
+
kinwrite(f, line.gsub("$FIRST_VAL$", replacements.first))
|
124
169
|
elsif replacements && line.include?("$LAST_VAL$")
|
125
|
-
f
|
170
|
+
kinwrite(f, line.gsub("$LAST_VAL$", replacements.last))
|
126
171
|
else
|
127
|
-
f
|
172
|
+
kinwrite(f, line)
|
128
173
|
end
|
129
174
|
end
|
130
175
|
f.puts ""
|
131
176
|
end
|
177
|
+
|
178
|
+
def self.kinwrite(f, line)
|
179
|
+
line.gsub!(/\t/, $site.config["haml_indentation"]) if ($site.config.has_key?("haml_indentation") && $site.config["haml_indentation"] != '\t')
|
180
|
+
f.puts(line)
|
181
|
+
end
|
182
|
+
|
183
|
+
def has_attribute?(att_name)
|
184
|
+
@attributes.map{|a| a.name}.include?(att_name)
|
185
|
+
end
|
132
186
|
|
133
187
|
private
|
188
|
+
|
189
|
+
def new_page_attributes
|
190
|
+
atts = $site.config["new_page_attributes"] || {}
|
191
|
+
atts.merge!({"Date" => Time.now.strftime("%B %d, %Y")}) if atts.has_key?("Date")
|
192
|
+
atts
|
193
|
+
end
|
134
194
|
|
135
195
|
def kv_to_attributes(keys, values)
|
136
196
|
attributes = {}
|
@@ -142,7 +202,7 @@ module Kinbote
|
|
142
202
|
attributes
|
143
203
|
end
|
144
204
|
|
145
|
-
def
|
205
|
+
def rem_title(attributes)
|
146
206
|
new_title = nil
|
147
207
|
title_keys = []
|
148
208
|
attributes.each do |key, value|
|
@@ -164,39 +224,24 @@ module Kinbote
|
|
164
224
|
|
165
225
|
def same_attributes(attributes, new_title)
|
166
226
|
return false if !new_title || new_title.size == 0 || new_title != @title
|
167
|
-
@attributes.sort_by{|a| a.name}.map{|a| "#{a.name}#{a.
|
227
|
+
@attributes.sort_by{|a| a.name}.map{|a| "#{a.name}#{a.values_for(self).sort_by{|v| v.value}.map{|v| v.value}.join}"}.join == attributes.to_a.sort_by{|a| a.first}.map{|a| "#{a.first}#{a.last.sort.join}"}.join
|
168
228
|
end
|
169
229
|
|
170
|
-
def add_attributes(attributes)
|
171
|
-
attributes.each do |name, values|
|
172
|
-
if BAD_ATTRIBUTE_VARNAMES.include?(varify(name))
|
173
|
-
$site.add_message("#{name} is an invalid attribute name")
|
174
|
-
next
|
175
|
-
end
|
176
|
-
g_att = $site.find_attribute(name)
|
177
|
-
g_att ? g_att.add_page(self, values) : g_att = Attribute.new(name, self, values); $site.add_attribute(g_att)
|
178
|
-
l_att = $site.find_attribute(name, self)
|
179
|
-
l_att ? l_att.add_page(self, values) : @attributes << Attribute.new(name, self, values, g_att)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
230
|
def srp(attribute_name, values)
|
184
231
|
page_matches = []
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
l_att.values.each do |val|
|
232
|
+
att = $site.find_attribute(attribute_name, self)
|
233
|
+
return page_matches if !att
|
234
|
+
att.values_for(self).each do |val|
|
189
235
|
next if values && values.size > 0 && !values.include?(val.value)
|
190
|
-
|
191
|
-
page_matches += (g_val.pages - [self]).map{|p| PageMatch.new(p, g_att, g_val)}
|
236
|
+
page_matches += (val.pages - [self]).map{|p| PageMatch.new(p, att, val)}
|
192
237
|
end
|
193
238
|
page_matches
|
194
239
|
end
|
195
240
|
|
196
241
|
def lrp(attribute_name)
|
197
|
-
|
198
|
-
return [] if !
|
199
|
-
(
|
242
|
+
att = $site.find_attribute(attribute_name)
|
243
|
+
return [] if !att || att.name.downcase == "date"
|
244
|
+
(att.pages - [self]).map{|p| PageMatch.new(p, att)}
|
200
245
|
end
|
201
246
|
|
202
247
|
end
|
data/lib/kinbote/site.rb
CHANGED
@@ -15,7 +15,6 @@ module Kinbote
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def load
|
18
|
-
load_pages
|
19
18
|
end
|
20
19
|
|
21
20
|
def reload
|
@@ -30,15 +29,15 @@ module Kinbote
|
|
30
29
|
nil
|
31
30
|
end
|
32
31
|
|
33
|
-
def find_attribute(name, page
|
32
|
+
def find_attribute(name, page=nil)
|
34
33
|
(page ? page.attributes : @attributes).each do |attribute|
|
35
34
|
return attribute if (attribute.name == name || attribute.varname == varify(name))
|
36
35
|
end
|
37
36
|
nil
|
38
37
|
end
|
39
38
|
|
40
|
-
def find_value(val, attribute
|
41
|
-
|
39
|
+
def find_value(val, attribute)
|
40
|
+
attribute.values.each do |value|
|
42
41
|
return value if (value.value == val && (attribute.name == value.attribute.name || attribute.varname == varify(value.attribute.name)))
|
43
42
|
end
|
44
43
|
nil
|
@@ -54,30 +53,64 @@ module Kinbote
|
|
54
53
|
|
55
54
|
def delete_page(slug)
|
56
55
|
page = find_page(slug)
|
57
|
-
@attributes.map{|att| att.
|
56
|
+
@attributes.map{|att| att.rem_page(page)}
|
58
57
|
@attributes.delete_if{|att| att.pages.size == 0}
|
59
58
|
page.delete_files([:html, :css])
|
60
59
|
@pages.delete_if{|p| p.slug == page.slug}
|
61
60
|
Page.add_metadata
|
62
61
|
end
|
63
62
|
|
64
|
-
def
|
65
|
-
@attributes.map{|att| att.
|
63
|
+
def rem_page_attributes(page)
|
64
|
+
@attributes.map{|att| att.rem_page(page)}
|
66
65
|
@attributes.delete_if{|att| att.pages.size == 0}
|
67
66
|
end
|
68
67
|
|
68
|
+
def rem_page_attribute(page, att_name)
|
69
|
+
@attributes.map{|att| att.rem_page(page) if att.name == att_name}
|
70
|
+
@attributes.delete_if{|att| att.pages.size == 0}
|
71
|
+
end
|
72
|
+
|
73
|
+
def bulk_update(slugs=[], action={})
|
74
|
+
return if !slugs || slugs.size == 0
|
75
|
+
slugs.each do |slug|
|
76
|
+
page = find_page(slug)
|
77
|
+
next if !page
|
78
|
+
if action["type"] == "add_attribute"
|
79
|
+
next if (!action.has_key?("attribute") || action["attribute"].strip.size == 0) || (!action.has_key?("value") || action["value"].strip.size == 0)
|
80
|
+
page.add_attribute(action["attribute"], [action["value"]])
|
81
|
+
elsif action["type"] == "rem_attribute"
|
82
|
+
next if !action.has_key?("attribute") || action["attribute"].strip.size == 0
|
83
|
+
if action.has_key?("value") && action["value"].strip.size > 0
|
84
|
+
page.rem_value(action["attribute"], action["value"])
|
85
|
+
else
|
86
|
+
page.rem_attribute(action["attribute"])
|
87
|
+
end
|
88
|
+
end
|
89
|
+
Page.add_metadata(page)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
69
93
|
def pages
|
70
|
-
@pages.sort{|x, y| x.title <=> y.title }
|
94
|
+
@pages.sort{|x, y| x.title.downcase <=> y.title.downcase }
|
71
95
|
end
|
72
96
|
|
73
97
|
def attributes
|
74
98
|
sorted_attributes(@attributes)
|
75
99
|
end
|
76
|
-
|
100
|
+
|
101
|
+
def print_sample_code?
|
102
|
+
@config.has_key?("print_sample_code") && @config["print_sample_code"] != false
|
103
|
+
end
|
104
|
+
|
77
105
|
def kinbote_path= (path); @kinbote_path = path; end
|
78
106
|
|
79
|
-
def add_attribute(attribute)
|
80
|
-
|
107
|
+
def add_attribute(attribute)
|
108
|
+
@attributes << attribute if !has_attribute?(attribute.name)
|
109
|
+
end
|
110
|
+
|
111
|
+
def has_attribute?(att_name)
|
112
|
+
@attributes.map{|a| a.name}.include?(att_name)
|
113
|
+
end
|
81
114
|
|
82
115
|
def add_message(message); @messages << message if !@messages.include?(message); end
|
83
116
|
def has_messages?; @messages.size > 0; end
|
@@ -85,13 +118,6 @@ module Kinbote
|
|
85
118
|
|
86
119
|
private
|
87
120
|
|
88
|
-
def load_pages
|
89
|
-
Dir.glob("#{@kinbote_path}/views/pages/**/*.{haml}").each do |file|
|
90
|
-
title, attributes = file_attributes(file)
|
91
|
-
create_page(title, file, attributes)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
121
|
def reload_pages
|
96
122
|
files = Dir.glob("#{@kinbote_path}/views/pages/**/*.{haml}")
|
97
123
|
files.each do |file|
|
@@ -100,6 +126,7 @@ module Kinbote
|
|
100
126
|
page = find_page(slug)
|
101
127
|
if page
|
102
128
|
next if File.size(file) == page.file_size(:html)
|
129
|
+
puts "Reload #{page.title}"
|
103
130
|
page.set_attributes(attributes.merge({"title" => [title]}))
|
104
131
|
page.reset_file_size(:html)
|
105
132
|
else
|
@@ -132,7 +159,7 @@ module Kinbote
|
|
132
159
|
end
|
133
160
|
|
134
161
|
def read_config
|
135
|
-
@config = (File.exist?("#{@kinbote_path}/config
|
162
|
+
@config = (File.exist?("#{@kinbote_path}/config.yml") ? YAML::load_file("#{@kinbote_path}/config.yml") : {"title" => "Kinbote Site"})
|
136
163
|
@config.each do |key, value|
|
137
164
|
Site.send(:define_method, varify(key).to_sym, Proc.new{ @config[key] }) if !Site.respond_to?(varify(key).to_sym)
|
138
165
|
end
|