static 0.1.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +213 -0
- data/README.md +50 -0
- data/Rakefile +40 -11
- data/bin/static +5 -93
- data/lib/static.rb +6 -145
- data/lib/static/cli.rb +32 -0
- data/lib/static/cli/app/download.rb +40 -0
- data/lib/static/version.rb +5 -0
- metadata +111 -79
- data/History.txt +0 -5
- data/Manifest.txt +0 -36
- data/README.txt +0 -307
- data/bin/cli.rbml +0 -321
- data/lib/collection.rb +0 -161
- data/lib/extentions/class.rb +0 -43
- data/lib/extentions/string.rb +0 -11
- data/lib/filebase.rb +0 -84
- data/lib/generator.rb +0 -20
- data/lib/page.rb +0 -135
- data/lib/site.rb +0 -153
- data/lib/xhtml.rb +0 -198
- data/templates/disco/attributes +0 -3
- data/templates/disco/display +0 -6
- data/templates/disco/feed +0 -21
- data/templates/disco/link_list +0 -6
- data/templates/disco/paginate +0 -1
- data/templates/helpers/content.rb +0 -393
- data/templates/helpers/prototype.js +0 -3277
- data/templates/layouts/default/contents.erbml +0 -8
- data/templates/layouts/default/copy/page.copy +0 -4
- data/templates/layouts/default/main_navigation.erbml +0 -10
- data/templates/layouts/default/page_head.erbml +0 -7
- data/templates/layouts/default/structure/default.rbml +0 -22
- data/templates/layouts/default/structure/footer.rbml +0 -6
- data/templates/layouts/default/stylesheets/default.css +0 -180
- data/templates/layouts/default/submenu.erbml +0 -13
- data/templates/page.copy +0 -3
- data/templates/site.info +0 -3
- data/templates/site.map +0 -15
- data/templates/submenu.copy +0 -0
data/lib/xhtml.rb
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
|
2
|
-
module Inclusion
|
3
|
-
def find_file_name page, what
|
4
|
-
tmp = nil
|
5
|
-
case what
|
6
|
-
when Hash
|
7
|
-
what.each { |desc, item| tmp = "#{page.file_name}_#{desc}_#{item}" }
|
8
|
-
else
|
9
|
-
tmp = what==:contents ? page.file_name : what.to_s
|
10
|
-
end
|
11
|
-
tmp+'.rbml'
|
12
|
-
end
|
13
|
-
def partial from, what
|
14
|
-
get from, "_#{what}"
|
15
|
-
end
|
16
|
-
def get from, what
|
17
|
-
case from
|
18
|
-
when :base
|
19
|
-
run_file Generator.act_on.home+"base/#{what}.rbml"
|
20
|
-
when :page
|
21
|
-
run_file Generator.act_on.home+"blueprint/#{Generator.page_location}#{find_file_name(Generator.act_on, what)}"
|
22
|
-
else
|
23
|
-
$active_site.pages.each { |page| run_file page.home+'blueprint/'+page.page_location+find_file_name(page, what) if page.name.as_file == from.to_s }
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def display how_many, collection, entry_bank=nil, &blk
|
28
|
-
col = load_collection(collection.to_s)
|
29
|
-
level = Generator.level
|
30
|
-
how_many = col.entries.size if how_many == :all
|
31
|
-
entry_bank ||= col.entries.dup
|
32
|
-
Generator.load col
|
33
|
-
Generator.act_on.instance_eval { def level; @level end; def level=(what); @level=what end }
|
34
|
-
Generator.act_on.level = level
|
35
|
-
how_many.times {
|
36
|
-
break if entry_bank.empty?
|
37
|
-
Generator.act_on.contents = entry_bank.shift
|
38
|
-
block_given? ? run_block(&blk) : run_file(Generator.act_on.display_file) rescue puts $!
|
39
|
-
}
|
40
|
-
Generator.act_on.instance_eval { @level = nil; undef :level; undef :level=}
|
41
|
-
Generator.unload
|
42
|
-
end
|
43
|
-
|
44
|
-
def include_partial
|
45
|
-
i Generator.include_text
|
46
|
-
Generator.include_text
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
module Rbml
|
51
|
-
module Language
|
52
|
-
module Doc
|
53
|
-
module Rss
|
54
|
-
def address_for what, options={}
|
55
|
-
where = options[:page] ? options[:page]+'.html' : ''
|
56
|
-
say = $active_site.info['server']['link']
|
57
|
-
$active_site.pages.each { |page|
|
58
|
-
if page.name.as_file == what.to_s
|
59
|
-
text ||= page.name
|
60
|
-
say += "#{page.in_site_link}#{where}"
|
61
|
-
end
|
62
|
-
}
|
63
|
-
say
|
64
|
-
end
|
65
|
-
|
66
|
-
def process_cdata what
|
67
|
-
what = what.to_s
|
68
|
-
exp = /\<\[.+?\]\>/
|
69
|
-
while(what =~ exp) do
|
70
|
-
what.sub!(exp) { |match|
|
71
|
-
eval(match.sub(/^\<\[/,'').sub(/\]\>$/, ''))
|
72
|
-
}
|
73
|
-
end
|
74
|
-
"<![CDATA[#{what}]]>"
|
75
|
-
end
|
76
|
-
def link_to where, text='', options={}
|
77
|
-
say=''
|
78
|
-
$active_site.pages.each { |page|
|
79
|
-
if page.name.as_file == where.to_s
|
80
|
-
text ||= page.name
|
81
|
-
say = "\"#{text}\":#{$active_site.info['server']['link']}#{page.in_site_link}"
|
82
|
-
end
|
83
|
-
}
|
84
|
-
say
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
module Rbml
|
92
|
-
module Language
|
93
|
-
module Doc
|
94
|
-
module Xhtml
|
95
|
-
def put_title
|
96
|
-
title(Generator.contents['title'])
|
97
|
-
end
|
98
|
-
def use_stylesheets *sheets
|
99
|
-
tmp = []
|
100
|
-
sheets.each { |s| tmp << s.to_s }
|
101
|
-
stylesheets Generator.level+'stylesheets/', tmp
|
102
|
-
end
|
103
|
-
alias :use_stylesheet :use_stylesheets
|
104
|
-
|
105
|
-
def image which, alt=nil
|
106
|
-
i "< image src='#{place}/#{which.to_s}' alt='#{alt||which.to_s}' />"
|
107
|
-
"<image src='#{Generator.level}resources/#{which.to_s}' alt='#{alt||which.to_s}' />"
|
108
|
-
end
|
109
|
-
def resource_address which
|
110
|
-
i "#{Generator.level}resources/#{which.to_s}"
|
111
|
-
"#{Generator.level}resources/#{which.to_s}"
|
112
|
-
end
|
113
|
-
def script_address which
|
114
|
-
i "#{Generator.level}scripts/#{which.to_s}"
|
115
|
-
"#{Generator.level}scripts/#{which.to_s}"
|
116
|
-
end
|
117
|
-
|
118
|
-
def put_stylesheets
|
119
|
-
styles = []
|
120
|
-
Generator.stylesheets.each{|style| styles << style if style}
|
121
|
-
styles.empty? ? '' : stylesheets(Generator.level+'stylesheets/', styles)
|
122
|
-
end
|
123
|
-
def breadcrumbs(join_by=nil)
|
124
|
-
join_by ||= " >> "
|
125
|
-
links = []
|
126
|
-
Generator.breadcrumbs.each {|b| links << (Generator.act_on.name.as_file==b.to_s ? Generator.act_on.name : link_to(b)) }
|
127
|
-
links.join(join_by)
|
128
|
-
end
|
129
|
-
def main_link_for what
|
130
|
-
link_to what
|
131
|
-
end
|
132
|
-
def feed name, title=nil
|
133
|
-
"<link rel=\"alternate\" type=\"application/rss+xml\" title=\"#{title||name.to_s}\" href=\"#{Generator.act_on.level}#{name.to_s}.rss\" />"
|
134
|
-
end
|
135
|
-
def link_to what, text=nil, options={}
|
136
|
-
where = options[:page] ? options[:page]+'.html' : ''
|
137
|
-
say=''
|
138
|
-
$active_site.pages.each { |page|
|
139
|
-
if page.name.as_file == what.to_s
|
140
|
-
text ||= page.name
|
141
|
-
say << "<a href='#{Generator.level}#{page.in_site_link}#{where}'>#{text}</a>"
|
142
|
-
end
|
143
|
-
}
|
144
|
-
say
|
145
|
-
end
|
146
|
-
def put what, options={}
|
147
|
-
t find_contents(what, options)
|
148
|
-
end
|
149
|
-
def plain_put what, options={}
|
150
|
-
find_contents(what, options)
|
151
|
-
end
|
152
|
-
def truncate what, how_many, options={}
|
153
|
-
options[:trail] ||= '...'
|
154
|
-
contents = find_contents(what)
|
155
|
-
contents = contents.size > how_many ? contents[0, how_many] + options[:trail] : contents
|
156
|
-
options[:textile] ? t(contents) : i(contents)
|
157
|
-
end
|
158
|
-
def find_contents what, options={}
|
159
|
-
parse_context(Generator.contents[what.to_s] || '')
|
160
|
-
end
|
161
|
-
|
162
|
-
def parse_context(what)
|
163
|
-
what = what.to_s
|
164
|
-
exp = /\<\[.+?\]\>/
|
165
|
-
while(what =~ exp) do
|
166
|
-
what.sub!(exp) { |match|
|
167
|
-
eval(match.sub(/^\<\[/,'').sub(/\]\>$/, ''))
|
168
|
-
}
|
169
|
-
end
|
170
|
-
exp = /\<!\[.+?\]\>/
|
171
|
-
while(what =~ exp) do
|
172
|
-
what.sub!(exp) { |match|
|
173
|
-
match.sub!(/^\<!\[/,'<[')
|
174
|
-
}
|
175
|
-
end
|
176
|
-
what
|
177
|
-
end
|
178
|
-
|
179
|
-
def site_map(options={}, item=nil, first_time=true)
|
180
|
-
pages = first_time ? "<ul>" : ''
|
181
|
-
item ||= $active_site.map['site_map']
|
182
|
-
case item
|
183
|
-
when String
|
184
|
-
pages << "<li>#{link_to(item.as_file)}</li>"
|
185
|
-
when Array : item.each {|i| pages << site_map(options, i, false)}
|
186
|
-
when Hash
|
187
|
-
item.each do |key, value|
|
188
|
-
pages << site_map(options, key, false)
|
189
|
-
pages << "<ul>#{site_map(options, value, false)}</ul>"
|
190
|
-
end
|
191
|
-
end
|
192
|
-
pages << "</ul>" if first_time
|
193
|
-
pages
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
198
|
-
end
|
data/templates/disco/attributes
DELETED
data/templates/disco/display
DELETED
data/templates/disco/feed
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
rss{
|
2
|
-
title <%=name.inspect%>
|
3
|
-
link $active_site.info['server']['link']
|
4
|
-
# description ''
|
5
|
-
language 'en-us'
|
6
|
-
pubDate Time.now.to_s
|
7
|
-
lastBuildDate Generator.last_built
|
8
|
-
docs 'http://blogs.law.harvard.edu/tech/rss'
|
9
|
-
generator 'static+rbml'
|
10
|
-
# managingEditor ''
|
11
|
-
# webMaster ''
|
12
|
-
display(5, :<%=name.as_file%>){
|
13
|
-
item {
|
14
|
-
title Generator.contents['title']
|
15
|
-
link Generator.contents['link'] if Generator.contents['link']
|
16
|
-
description { process_cdata(Generator.contents['entry']) }
|
17
|
-
pubDate Generator.contents[:publish]
|
18
|
-
guid { address_for(:<%=name.as_file%>, :page => Generator.contents[:id]) }
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
data/templates/disco/link_list
DELETED
data/templates/disco/paginate
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
display 1, :<%=name%>, Generator.entry_bank
|
@@ -1,393 +0,0 @@
|
|
1
|
-
|
2
|
-
require 'camping'
|
3
|
-
require 'static'
|
4
|
-
|
5
|
-
include Static
|
6
|
-
Camping.goes :Content
|
7
|
-
|
8
|
-
@home = File.dirname(__FILE__)+'/..'
|
9
|
-
File.open("#{@home}/project_info/site.info") { |yf| $info = YAML::load( yf ) }
|
10
|
-
Static::setup_home
|
11
|
-
|
12
|
-
$active_site = load_site $info['working_name']
|
13
|
-
|
14
|
-
module Content::Controllers
|
15
|
-
class Static < R '/resource_bank/(.+)'
|
16
|
-
MIME_TYPES = {'.css' => 'text/css', '.js' => 'text/javascript', '.jpg' => 'image/jpeg'}
|
17
|
-
PATH = File.expand_path(File.dirname(__FILE__))
|
18
|
-
|
19
|
-
def get(path)
|
20
|
-
@headers['Content-Type'] = MIME_TYPES[path[/\.\w+$/, 0]] || "text/plain"
|
21
|
-
unless path.include?("..")
|
22
|
-
@headers['X-Sendfile'] = "#{PATH}/#{path}"
|
23
|
-
else
|
24
|
-
@status = "403"
|
25
|
-
"403 - Invalid path"
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class GenerateSite < R '/site/generate'
|
31
|
-
def get
|
32
|
-
$active_site.destroy $active_site.site_loc
|
33
|
-
$active_site.info['paginate'].each { |page, collection| paginate page } if $active_site.info['paginate']
|
34
|
-
$active_site.generate
|
35
|
-
publish_feeds :local
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class PublishSite < R '/site/publish'
|
40
|
-
def get
|
41
|
-
$active_site.destroy $active_site.site_loc
|
42
|
-
$active_site.info['paginate'].each { |page, collection| paginate page } if $active_site.info['paginate']
|
43
|
-
$active_site.generate
|
44
|
-
publish_feeds
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
class HideCollection < R '/collection/hide/(.+)'
|
50
|
-
def get name
|
51
|
-
@headers['Content-Type'] = 'text/javascript'
|
52
|
-
@name = name
|
53
|
-
render :_hide_collection
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class ListCollection < R '/collection/list/(.+)'
|
58
|
-
def get name
|
59
|
-
@headers['Content-Type'] = 'text/javascript'
|
60
|
-
@name = name
|
61
|
-
@collection = load_collection name
|
62
|
-
render :_list_collection
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
class ViewEntry < R '/collection/(.+)/entry/(.+)'
|
67
|
-
def get collection, entry
|
68
|
-
@headers['Content-Type'] = 'text/javascript'
|
69
|
-
@name = collection
|
70
|
-
@collection = load_collection collection
|
71
|
-
@collection.load_entries
|
72
|
-
@entry = @collection.find_entry entry
|
73
|
-
render :_view_entry
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class ReloadEntrySection < R '/reload/collection/(.+)/entry/(.+)/section/(.+)'
|
78
|
-
def get collection, entry, key
|
79
|
-
@headers['Content-Type'] = 'text/javascript'
|
80
|
-
@name = collection
|
81
|
-
@collection = load_collection collection
|
82
|
-
@collection.load_entries
|
83
|
-
@entry = @collection.find_entry entry
|
84
|
-
@section = key
|
85
|
-
render :_reload_entry_section
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
class PublishEntry < R '/publish/collection/(\w+)/entry/(\w+)'
|
90
|
-
def get collection, entry
|
91
|
-
@headers['Content-Type'] = 'text/javascript'
|
92
|
-
@name = collection
|
93
|
-
@collection = load_collection collection
|
94
|
-
@collection.set_to_publish entry
|
95
|
-
@collection.load_entries
|
96
|
-
render :_list_collection
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
class DeleteEntry < R '/delete/collection/(.+)/entry/(.+)'
|
101
|
-
def get collection, entry
|
102
|
-
@headers['Content-Type'] = 'text/javascript'
|
103
|
-
@name = collection
|
104
|
-
@collection = load_collection collection
|
105
|
-
@collection.delete entry
|
106
|
-
@collection.load_entries
|
107
|
-
render :_list_collection
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
class EditEntry < R '/edit/collection/(.+)/entry/(.+)/section/(.+)'
|
112
|
-
def get collection, entry, key
|
113
|
-
@headers['Content-Type'] = 'text/javascript'
|
114
|
-
@name = collection
|
115
|
-
@collection = load_collection collection
|
116
|
-
@collection.load_entries
|
117
|
-
@entry = @collection.find_entry entry
|
118
|
-
@section = key
|
119
|
-
render :_edit_entry_section
|
120
|
-
end
|
121
|
-
|
122
|
-
def post collection, entry, key
|
123
|
-
@headers['Content-Type'] = 'text/javascript'
|
124
|
-
|
125
|
-
@name = collection
|
126
|
-
@collection = load_collection collection
|
127
|
-
@collection.load_entries
|
128
|
-
@collection.find_entry(entry)[key] = input["#{key}_value"]
|
129
|
-
@entry = @collection.save_entry entry
|
130
|
-
@section = key
|
131
|
-
render :_reload_entry_section
|
132
|
-
end
|
133
|
-
end
|
134
|
-
class Index < R '/'
|
135
|
-
def get
|
136
|
-
render :index
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
class Content < R '/(\w+)'
|
141
|
-
def get page_name
|
142
|
-
@page = Page.find page_name.as_file
|
143
|
-
@page.load_contents
|
144
|
-
render :_content
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
class Reload < R '/reload/(\w+)/(\w+)'
|
149
|
-
def get page_name, section
|
150
|
-
@page = Page.find page_name.as_file
|
151
|
-
@page.load_contents
|
152
|
-
@key = section
|
153
|
-
@value = @page.contents[section]
|
154
|
-
render :_section
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
class AddEntry < R '/add_entry/collection/(\w+)'
|
159
|
-
def get collection
|
160
|
-
@name = collection
|
161
|
-
@collection = load_collection collection
|
162
|
-
@collection.load_entries
|
163
|
-
@entry = @collection.add_entry
|
164
|
-
@entry = @collection.load_entry @entry
|
165
|
-
@collection.load_entries
|
166
|
-
render :_view_entry
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
class Edit < R '/edit/(\w+)/(\w+)'
|
171
|
-
def get page_name, section
|
172
|
-
page = Page.find page_name.as_file
|
173
|
-
page.load_contents
|
174
|
-
@page_name = page_name.as_file
|
175
|
-
@text = page.contents[section]
|
176
|
-
@title = section
|
177
|
-
render :_edit_section
|
178
|
-
end
|
179
|
-
|
180
|
-
def post page_name, section
|
181
|
-
@headers['Content-Type'] = 'text/javascript'
|
182
|
-
@page = Page.find page_name.as_file
|
183
|
-
@page.load_contents
|
184
|
-
@old_key = section
|
185
|
-
@key = input["#{section}_key"]
|
186
|
-
@value = input["#{section}_value"]
|
187
|
-
if @key == section
|
188
|
-
@page.contents[section] = @value
|
189
|
-
else
|
190
|
-
@page.contents[section] = nil
|
191
|
-
@page.contents[@key] = @value
|
192
|
-
end
|
193
|
-
@page.save_contents
|
194
|
-
@page.load_contents
|
195
|
-
|
196
|
-
render :_reload_section
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
module Content::Views
|
202
|
-
def site_map(options={}, item=nil, first_time=true)
|
203
|
-
pages = first_time ? "<ul>" : ''
|
204
|
-
item ||= $active_site.map['site_map']
|
205
|
-
case item
|
206
|
-
when String
|
207
|
-
pages << "<li>#{link_to(item)}</li>"
|
208
|
-
when Array : item.each {|i| pages << site_map(options, i, false)}
|
209
|
-
when Hash
|
210
|
-
item.each do |key, value|
|
211
|
-
pages << site_map(options, key, false)
|
212
|
-
pages << "<ul>#{site_map(options, value, false)}</ul>"
|
213
|
-
end
|
214
|
-
end
|
215
|
-
pages << "</ul>" if first_time
|
216
|
-
pages
|
217
|
-
end
|
218
|
-
|
219
|
-
def link_to page, name=nil; name||=page; a name, :href=>'#', :onclick => "new Ajax.Updater('main', '/#{page.as_file}',{asynchronous:true, evalScripts:true, method:'get'}); return false;" end
|
220
|
-
|
221
|
-
def layout
|
222
|
-
html do
|
223
|
-
head{
|
224
|
-
title { 'Content Editing For Static' }
|
225
|
-
script :src => "resource_bank/prototype.js", :type => "text/javascript"
|
226
|
-
}
|
227
|
-
body {
|
228
|
-
table {
|
229
|
-
ul{
|
230
|
-
li{
|
231
|
-
self << a('generate site locally', :href => '#', :onclick => "new Ajax.Request('site/generate', {asynchronous:true, evalScripts:true, method:'get'}); return false;")
|
232
|
-
}
|
233
|
-
li{
|
234
|
-
self << a('local preview', :href => $active_site.info['local']['link'], :target => 'blank')
|
235
|
-
} if $active_site.info['local'] and $active_site.info['local']['link']
|
236
|
-
li{
|
237
|
-
self << a('publish site', :href => '#', :onclick => "new Ajax.Request('site/publish', {asynchronous:true, evalScripts:true, method:'get'}); return false;")
|
238
|
-
} if $active_site.info['server'] and $active_site.info['server']['link'] and $active_site.info['server']['address'] and $active_site.info['server']['directory'] and $active_site.info['user_name']
|
239
|
-
li{
|
240
|
-
self << a('go to live site', :href => $active_site.info['server']['link'], :target => 'blank' )
|
241
|
-
} if $active_site.info['server'] and $active_site.info['server']['link']
|
242
|
-
}
|
243
|
-
tr{
|
244
|
-
td(:id => 'page_select', :valign=>'top', :width=> '250px'){
|
245
|
-
self<< site_map({}, $active_site.map['site_map'])
|
246
|
-
$active_site.info['feeds'].each do |f|
|
247
|
-
div(:id=>"#{f}_collection"){self << a(f, :href=>'#', :onclick => "new Ajax.Request('collection/list/#{f}', {asynchronous:true, evalScripts:true, method:'get'}); return false;")}
|
248
|
-
end if $active_site.info['feeds']
|
249
|
-
}
|
250
|
-
td(:id=>'main', :valign =>'top'){ self << yield }
|
251
|
-
}
|
252
|
-
}
|
253
|
-
}
|
254
|
-
end
|
255
|
-
end
|
256
|
-
|
257
|
-
def index
|
258
|
-
p 'there are no instructions. do what feels right.'
|
259
|
-
end
|
260
|
-
|
261
|
-
def _content
|
262
|
-
h4 "copy for #{@page.name}"
|
263
|
-
if @page.contents['title']
|
264
|
-
span(:id => 'title'){
|
265
|
-
h4 {
|
266
|
-
self << a('title', :href=>"#", :onclick => "new Ajax.Updater('title', 'edit/#{@page.file_name}/title', { asynchronous:true, method:'get' });")
|
267
|
-
}
|
268
|
-
pre @page.contents['title']
|
269
|
-
}
|
270
|
-
end
|
271
|
-
@page.contents.each do |key, value|
|
272
|
-
unless key == 'title' or key == 'stylesheets'
|
273
|
-
span(:id => key){
|
274
|
-
h4 {
|
275
|
-
self << a(key, :href=>"#", :onclick => "new Ajax.Updater('#{key}', 'edit/#{@page.file_name}/#{key}', { asynchronous:true, method:'get' });")
|
276
|
-
}
|
277
|
-
pre value
|
278
|
-
}
|
279
|
-
end
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
def _edit_section
|
284
|
-
form(:onsubmit => "new Ajax.Request('/edit/#{@page_name}/#{@title}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"){
|
285
|
-
|
286
|
-
if @title == 'title'
|
287
|
-
h4 'title'
|
288
|
-
input :type => 'hidden', :value => @title, :name =>"#{@title}_key"
|
289
|
-
input :type => 'text', :name =>"#{@title}_value", :value => @text
|
290
|
-
else
|
291
|
-
input :type => 'text', :value => @title, :name =>"#{@title}_key"
|
292
|
-
textarea(:cols => '90', :rows => '30', :name => "#{@title}_value"){
|
293
|
-
self << @text
|
294
|
-
}
|
295
|
-
end
|
296
|
-
input :type => 'submit', :value => 'submit', :name => 'submit'
|
297
|
-
a 'cancel', :href=> "#", :onclick => "new Ajax.Updater('#{@title}', '/reload/#{@page_name}/#{@title}', {asynchronous:true, method:'get'}); return false;"
|
298
|
-
}
|
299
|
-
end
|
300
|
-
|
301
|
-
def _edit_entry_section
|
302
|
-
form(:onsubmit => "new Ajax.Request('/edit/collection/#{@name}/entry/#{@entry[:id]}/section/#{@section}', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"){
|
303
|
-
if @section == "title"
|
304
|
-
input :type => 'text', :name =>"title_value", :value => @entry[@section]
|
305
|
-
else
|
306
|
-
textarea(:cols => '90', :rows => '30', :name => "#{@section}_value"){
|
307
|
-
self << @entry[@section]
|
308
|
-
}
|
309
|
-
end
|
310
|
-
input :type => 'submit', :value => 'submit', :name => 'submit'
|
311
|
-
a 'cancel', :href=> "#", :onclick => "new Ajax.Updater('#{@section}_attribute', '/reload/collection/#{@name}/entry/#{@entry[:id]}/section/#{@section}', {asynchronous:true, method:'get'}); return false;"
|
312
|
-
}
|
313
|
-
end
|
314
|
-
|
315
|
-
def _reload_entry_section
|
316
|
-
self << _list_collection if @section == 'title'
|
317
|
-
self << "$('attribute_#{@section}').replace("
|
318
|
-
if @section =="title"
|
319
|
-
h4(:id => "attribute_title"){self<< a(@entry["title"]||@entry[:id], :href=>'#', :onclick => "new Ajax.Updater('attribute_title', 'edit/collection/#{@name}/entry/#{@entry[:id]}/section/title', { asynchronous:true, method:'get' });")}
|
320
|
-
else
|
321
|
-
span(:id => "attribute_#{@section}"){
|
322
|
-
self << a(@section, :href=>"#", :onclick => "new Ajax.Updater('attribute_#{@section}', 'edit/collection/#{@name}/entry/#{@entry[:id]}/section/#{@section}', { asynchronous:true, method:'get' });")
|
323
|
-
pre(@entry[@section])
|
324
|
-
}
|
325
|
-
end
|
326
|
-
self << ")"
|
327
|
-
end
|
328
|
-
|
329
|
-
def _section
|
330
|
-
span(:id => @key){
|
331
|
-
h4 {
|
332
|
-
self << a(@key, :href=>"#", :onclick => "new Ajax.Updater('#{@key}', 'edit/#{@page.file_name}/#{@key}', { asynchronous:true, method:'get' });")
|
333
|
-
}
|
334
|
-
pre @value
|
335
|
-
}
|
336
|
-
end
|
337
|
-
|
338
|
-
def _reload_section
|
339
|
-
self << "$('#{@old_key}').replace("
|
340
|
-
_section
|
341
|
-
self << ")"
|
342
|
-
end
|
343
|
-
|
344
|
-
def _hide_collection
|
345
|
-
self << "$('#{@name}_collection').replace("
|
346
|
-
div(:id=>"#{@name}_collection"){self << a(@name, :href=>'#', :onclick => "new Ajax.Request('collection/list/#{@name}', {asynchronous:true, evalScripts:true, method:'get'}); return false;")}
|
347
|
-
self << ")"
|
348
|
-
end
|
349
|
-
|
350
|
-
def _list_collection
|
351
|
-
self << "$('#{@name}_collection').replace("
|
352
|
-
div(:id => "#{@name}_collection"){
|
353
|
-
a(@name, :href=>'#', :onclick => "new Ajax.Request('collection/hide/#{@name}', {asynchronous:true, evalScripts:true, method:'get'}); return false;")
|
354
|
-
a("+add+", :href=>'#', :onclick => "new Ajax.Updater('main', 'add_entry/collection/#{@name}', {asynchronous:true, evalScripts:true, method:'get'}); return false;")
|
355
|
-
ul{
|
356
|
-
li "unpublished"
|
357
|
-
@collection.unpublished.each do |e|
|
358
|
-
li{
|
359
|
-
self << a(e['title']||e[:id], :href=>'#', :onclick=>"new Ajax.Updater('main', 'collection/#{@name}/entry/#{e[:id]}',{asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
360
|
-
self << a('publish', :href => '#', :onclick=>"new Ajax.Request('publish/collection/#{@name}/entry/#{e[:id]}',{asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
361
|
-
self << a('delete', :href => '#', :onclick=>"new Ajax.Request('delete/collection/#{@name}/entry/#{e[:id]}',{asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
362
|
-
}
|
363
|
-
end
|
364
|
-
}
|
365
|
-
ul{
|
366
|
-
li "published"
|
367
|
-
@collection.entries.each do |e|
|
368
|
-
li{
|
369
|
-
self << a(e['title']||e[:id], :href=>'#', :onclick=>"new Ajax.Updater('main', 'collection/#{@name}/entry/#{e[:id]}',{asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
370
|
-
unless e[:publish]
|
371
|
-
self << a('publish', :href => '#', :onclick=>"new Ajax.Request('publish/collection/#{@name}/entry/#{e[:id]}', {asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
372
|
-
self << a('delete', :href => '#', :onclick=>"new Ajax.Request('delete/collection/#{@name}/entry/#{e[:id]}',{asynchronous:true, evalScripts:true, method:'get'}); return false; ")
|
373
|
-
end
|
374
|
-
}
|
375
|
-
end
|
376
|
-
}
|
377
|
-
}
|
378
|
-
self << ");"
|
379
|
-
end
|
380
|
-
|
381
|
-
def _view_entry
|
382
|
-
h4(:id => "attribute_title"){self<< a(@entry["title"]||@entry[:id], :href=>'#', :onclick => "new Ajax.Updater('attribute_title', 'edit/collection/#{@name}/entry/#{@entry[:id]}/section/title', { asynchronous:true, method:'get' });")}
|
383
|
-
@entry.each {|key, value|
|
384
|
-
unless key=='title' or key.kind_of? Symbol
|
385
|
-
span(:id => "attribute_#{key}"){
|
386
|
-
self << a(key, :href=>"#", :onclick => "new Ajax.Updater('attribute_#{key}', 'edit/collection/#{@name}/entry/#{@entry[:id]}/section/#{key}', { asynchronous:true, method:'get' });")
|
387
|
-
pre(@entry[key])
|
388
|
-
}
|
389
|
-
end
|
390
|
-
}
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|