Commit b4494c043d66d8b9bb6c5b71add813c326f4bebe
1 parent
d26c5c26
Exists in
master
and in
22 other branches
ActionItem93: dropping comatose. :(
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@933 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
28 changed files
with
28 additions
and
853 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
@@ -15,347 +15,4 @@ class CmsController < MyProfileController | @@ -15,347 +15,4 @@ class CmsController < MyProfileController | ||
15 | end | 15 | end |
16 | 16 | ||
17 | 17 | ||
18 | - public | ||
19 | - | ||
20 | - ############################################################# | ||
21 | - # everything below was copied from comatose | ||
22 | - ############################################################# | ||
23 | - | ||
24 | - define_option :original_template_root, nil | ||
25 | - define_option :plugin_layout_path, File.join( '..', '..', '..', 'vendor', 'plugins', 'comatose', 'views', 'layouts' ) | ||
26 | - | ||
27 | - before_filter :handle_authorization | ||
28 | - before_filter :set_content_type | ||
29 | - | ||
30 | - # Shows the page tree | ||
31 | - def index | ||
32 | - @root_pages = [fetch_root_page].flatten | ||
33 | - end | ||
34 | - | ||
35 | - # Edit a specfic page (posts back) | ||
36 | - def edit | ||
37 | - # Clear the page cache for this page... ? | ||
38 | - @page = page_class.find params[:id] | ||
39 | - @root_pages = [fetch_root_page].flatten | ||
40 | - if request.post? | ||
41 | - @page.update_attributes(params[:page]) | ||
42 | - @page.updated_on = Time.now | ||
43 | - @page.author = fetch_author_name | ||
44 | - if @page.save | ||
45 | - expire_cms_page @page | ||
46 | - expire_cms_fragment @page | ||
47 | - flash[:notice] = "Saved changes to '#{@page.title}'" | ||
48 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
49 | - end | ||
50 | - end | ||
51 | - end | ||
52 | - | ||
53 | - # Create a new page (posts back) | ||
54 | - def new | ||
55 | - @root_pages = [fetch_root_page].flatten | ||
56 | - if request.post? | ||
57 | - @page = page_class.new params[:page] | ||
58 | - @page.author = fetch_author_name | ||
59 | - if @page.save | ||
60 | - flash[:notice] = "Created page '#{@page.title}'" | ||
61 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
62 | - end | ||
63 | - else | ||
64 | - @page = page_class.new(:parent_id=>(params[:parent] || nil)) | ||
65 | - end | ||
66 | - end | ||
67 | - | ||
68 | - # Saves position of child pages | ||
69 | - def reorder | ||
70 | - # If it's AJAX, do our thing and move on... | ||
71 | - if request.xhr? | ||
72 | - params["page_list_#{params[:id]}"].each_with_index { |id,idx| page_class.update(id, :position => idx) } | ||
73 | - expire_cms_page page_class.find(params[:id]) | ||
74 | - render :text=>'Updated sort order', :layout=>false | ||
75 | - else | ||
76 | - @page = page_class.find params[:id] | ||
77 | - if params.has_key? :cmd | ||
78 | - @target = page_class.find params[:page] | ||
79 | - case params[:cmd] | ||
80 | - when 'up' then @target.move_higher | ||
81 | - when 'down' then @target.move_lower | ||
82 | - end | ||
83 | - redirect_to :action=>'reorder', :id=>@page | ||
84 | - end | ||
85 | - end | ||
86 | - end | ||
87 | - | ||
88 | - # Allows comparing between two versions of a page's content | ||
89 | - def versions | ||
90 | - @page = page_class.find params[:id] | ||
91 | - @version_num = (params[:version] || @page.versions.length).to_i | ||
92 | - @version = @page.find_version(@version_num) | ||
93 | - end | ||
94 | - | ||
95 | - # Reverts a page to a specific version... | ||
96 | - def set_version | ||
97 | - if request.post? | ||
98 | - @page = page_class.find params[:id] | ||
99 | - @version_num = params[:version] | ||
100 | - @page.revert_to!(@version_num) | ||
101 | - end | ||
102 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
103 | - end | ||
104 | - | ||
105 | - # Deletes the specified page | ||
106 | - def delete | ||
107 | - @page = page_class.find params[:id] | ||
108 | - if request.post? | ||
109 | - expire_cms_pages_from_bottom @page | ||
110 | - expire_cms_fragments_from_bottom @page | ||
111 | - @page.destroy | ||
112 | - flash[:notice] = "Deleted page '#{@page.title}'" | ||
113 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
114 | - end | ||
115 | - end | ||
116 | - | ||
117 | - # Returns a preview of the page content... | ||
118 | - def preview | ||
119 | - begin | ||
120 | - page = page_class.new(params[:page]) | ||
121 | - page.author = fetch_author_name | ||
122 | - if params.has_key? :version | ||
123 | - content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} ) | ||
124 | - else | ||
125 | - content = page.to_html( {'params'=>params.stringify_keys} ) | ||
126 | - end | ||
127 | - rescue SyntaxError | ||
128 | - content = "<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\</, '<')}</pre></p>" | ||
129 | - rescue | ||
130 | - content = "<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\</, '<')}</pre></p>" | ||
131 | - end | ||
132 | - render :text=>content, :layout => false | ||
133 | - end | ||
134 | - | ||
135 | - # Expires the entire page cache | ||
136 | - def expire_page_cache | ||
137 | - expire_cms_pages_from_bottom( fetch_root_page ) | ||
138 | - expire_cms_fragments_from_bottom( fetch_root_page ) | ||
139 | - flash[:notice] = "Page cache has been flushed" | ||
140 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
141 | - end | ||
142 | - | ||
143 | - # Walks the page tree and generates HTML files in your /public | ||
144 | - # folder... It will skip pages that have a 'nocache' keyword | ||
145 | - # TODO: Make page cache generation work when in :plugin mode | ||
146 | - def generate_page_cache | ||
147 | - if runtime_mode == :plugin | ||
148 | - @errors = ["Page cache cannot be generated in plugin mode"] | ||
149 | - else | ||
150 | - @errors = generate_all_pages_html(params) | ||
151 | - end | ||
152 | - if @errors.length == 0 | ||
153 | - flash[:notice] = "Pages Cached Successfully" | ||
154 | - else | ||
155 | - flash[:notice] = "Pages Cache Error(s): #{@errors.join(', ')}" | ||
156 | - flash[:cache_errors] = @errors | ||
157 | - end | ||
158 | - redirect_to :controller=>self.controller_name, :action=>'index' | ||
159 | - end | ||
160 | - | ||
161 | - | ||
162 | - protected | ||
163 | - | ||
164 | - def handle_authorization | ||
165 | - if Comatose.config.admin_authorization.is_a? Proc | ||
166 | - instance_eval &Comatose.config.admin_authorization | ||
167 | - elsif Comatose.config.admin_authorization.is_a? Symbol | ||
168 | - send(Comatose.config.admin_authorization) | ||
169 | - elsif defined? authorize | ||
170 | - authorize | ||
171 | - else | ||
172 | - true | ||
173 | - end | ||
174 | - end | ||
175 | - | ||
176 | - def fetch_author_name | ||
177 | - if Comatose.config.admin_get_author.is_a? Proc | ||
178 | - instance_eval &Comatose.config.admin_get_author | ||
179 | - elsif Comatose.config.admin_get_author.is_a? Symbol | ||
180 | - send(Comatose.config.admin_get_author) | ||
181 | - elsif defined? get_author | ||
182 | - get_author | ||
183 | - end | ||
184 | - end | ||
185 | - | ||
186 | - # Can be overridden -- return your root comtase page | ||
187 | - def fetch_root_page | ||
188 | - if Comatose.config.admin_get_root_page.is_a? Proc | ||
189 | - instance_eval &Comatose.config.admin_get_root_page | ||
190 | - elsif Comatose.config.admin_get_root_page.is_a? Symbol | ||
191 | - send(Comatose.config.admin_get_root_page) | ||
192 | - elsif defined? get_root_page | ||
193 | - get_root_page | ||
194 | - end | ||
195 | - end | ||
196 | - | ||
197 | - # Sets the HTTP content-type header based on what's configured | ||
198 | - # in Comatose.config.content_type | ||
199 | - def set_content_type | ||
200 | - response.headers["Content-Type"] = "text/html; charset=#{Comatose.config.content_type}" unless Comatose.config.content_type.nil? | ||
201 | - end | ||
202 | - | ||
203 | - # Calls generate_page_html for each mount point.. | ||
204 | - def generate_all_pages_html(params={}) | ||
205 | - @errors = [] | ||
206 | - @been_cached = [] | ||
207 | - Comatose.mount_points.each do |root_info| | ||
208 | - page_class.active_mount_info = root_info | ||
209 | - generate_page_html(page_class.find_by_path( root_info[:index] ), root_info, params) | ||
210 | - end | ||
211 | - @errors | ||
212 | - end | ||
213 | - | ||
214 | - # Accepts a Comatose Page and a root_info object to generate | ||
215 | - # the page as a static HTML page -- using the layout that was | ||
216 | - # defined on the mount point | ||
217 | - def generate_page_html(page, root_info, params={}) | ||
218 | - @been_cached ||= [] | ||
219 | - unless page.has_keyword? :nocache or @been_cached.include? page.id | ||
220 | - uri = page.uri | ||
221 | - uri = "#{uri}/index".split('/').flatten.join('/') if page.full_path == root_info[:index] | ||
222 | - @page = Comatose::PageWrapper.new(page) | ||
223 | - begin | ||
224 | - page_layout = get_page_layout(root_info) | ||
225 | - #puts "mode = #{runtime_mode}, layout = #{page_layout}, template_root = #{template_root}, original_template_root = #{original_template_root}" | ||
226 | - html = render_to_string( :text=>page.to_html({'params'=>params.stringify_keys}), :layout=>page_layout ) | ||
227 | - cache_page( html, uri ) | ||
228 | - rescue | ||
229 | - logger.error "Comatose CMS Page Cache Exception: #{$!}" | ||
230 | - @errors << "(#{page}/#{page.slug}) - #{$!}" | ||
231 | - end | ||
232 | - @been_cached << page.id | ||
233 | - # recurse... | ||
234 | - page.children.each do |child| | ||
235 | - generate_page_html(child, root_info) | ||
236 | - end | ||
237 | - end | ||
238 | - end | ||
239 | - | ||
240 | - # Calls the class methods of the same name... | ||
241 | - def expire_cms_page(page) | ||
242 | - self.class.expire_cms_page(page) | ||
243 | - end | ||
244 | - def expire_cms_pages_from_bottom(page) | ||
245 | - self.class.expire_cms_pages_from_bottom(page) | ||
246 | - end | ||
247 | - | ||
248 | - | ||
249 | - # expire the page from the fragment cache | ||
250 | - def expire_cms_fragment(page) | ||
251 | - key = page.full_path.gsub(/\//, '+') | ||
252 | - expire_fragment(key) | ||
253 | - end | ||
254 | - | ||
255 | - # expire pages starting at a specific node | ||
256 | - def expire_cms_fragments_from_bottom(page) | ||
257 | - pages = page.is_a?(Array) ? page : [page] | ||
258 | - pages.each do |page| | ||
259 | - page.children.each {|c| expire_cms_fragments_from_bottom( c ) } if !page.children.empty? | ||
260 | - expire_cms_fragment( page ) | ||
261 | - end | ||
262 | - end | ||
263 | - | ||
264 | - # Class Methods... | ||
265 | - class << self | ||
266 | - | ||
267 | - # Walks all the way down, and back up the tree -- the allows the expire_cms_page | ||
268 | - # to delete empty directories better | ||
269 | - def expire_cms_pages_from_bottom(page) | ||
270 | - pages = page.is_a?(Array) ? page : [page] | ||
271 | - pages.each do |page| | ||
272 | - page.children.each {|c| expire_cms_pages_from_bottom( c ) } if !page.children.empty? | ||
273 | - expire_cms_page( page ) | ||
274 | - end | ||
275 | - end | ||
276 | - | ||
277 | - # Expire the page from all the mount points... | ||
278 | - def expire_cms_page(page) | ||
279 | - Comatose.mount_points.each do |path_info| | ||
280 | - page_class.active_mount_info = path_info | ||
281 | - expire_page(page.uri) | ||
282 | - # If the page is the index page for the root, expire it too | ||
283 | - if path_info[:root] == page.uri | ||
284 | - expire_page("#{path_info[:root]}/index") | ||
285 | - end | ||
286 | - begin # I'm not sure this matters too much -- but it keeps things clean | ||
287 | - dir_path = File.join(RAILS_ROOT, 'public', page.uri[1..-1]) | ||
288 | - Dir.delete( dir_path ) if FileTest.directory?( dir_path ) and !page.parent.nil? | ||
289 | - rescue | ||
290 | - # It probably isn't empty -- just as well we leave it be | ||
291 | - #STDERR.puts " - Couldn't delete dir #{dir_path} -> #{$!}" | ||
292 | - end | ||
293 | - end | ||
294 | - end | ||
295 | - | ||
296 | - # Returns a path to plugin layout, if it's unspecified, otherwise | ||
297 | - # a path to an application layout... | ||
298 | - def get_page_layout(params) | ||
299 | - if params[:layout] == 'comatose_content' | ||
300 | - File.join(plugin_layout_path, params[:layout]) | ||
301 | - else | ||
302 | - params[:layout] | ||
303 | - end | ||
304 | - end | ||
305 | - | ||
306 | - def configure_template_root | ||
307 | - if self.runtime_mode == :unknown | ||
308 | - if FileTest.exist? File.join(RAILS_ROOT, 'public', 'javascripts', 'comatose_admin.js') | ||
309 | - self.runtime_mode = :application | ||
310 | - else | ||
311 | - self.runtime_mode = :plugin | ||
312 | - end | ||
313 | - end | ||
314 | - end | ||
315 | - | ||
316 | - def runtime_mode | ||
317 | - @@runtime_mode ||= :unknown | ||
318 | - end | ||
319 | - | ||
320 | - def runtime_mode=(mode) | ||
321 | - case mode | ||
322 | - when :plugin | ||
323 | - self.original_template_root = self.template_root | ||
324 | - self.template_root = File.join( File.dirname(__FILE__), '..', '..', 'views') | ||
325 | - when :application | ||
326 | - self.template_root = self.original_template_root if self.original_template_root | ||
327 | - end | ||
328 | - @@runtime_mode = mode | ||
329 | - end | ||
330 | - | ||
331 | - end | ||
332 | - | ||
333 | - # Check to see if we are in 'embedded' mode, or are being 'customized' | ||
334 | - # embedded = runtime_mode of :plugin | ||
335 | - # customized = runtime_mode of :application | ||
336 | - configure_template_root | ||
337 | - | ||
338 | - # | ||
339 | - # Include any modules... | ||
340 | - Comatose.config.admin_includes.each do |mod| | ||
341 | - if mod.is_a? String | ||
342 | - include mod.constantize | ||
343 | - elsif mod.is_a? Symbol | ||
344 | - include mod.to_s.classify.constantize | ||
345 | - else | ||
346 | - include mod | ||
347 | - end | ||
348 | - end | ||
349 | - | ||
350 | - # Include any helpers... | ||
351 | - Comatose.config.admin_helpers.each do |mod| | ||
352 | - if mod.is_a? String | ||
353 | - helper mod.constantize | ||
354 | - elsif mod.is_a? Symbol | ||
355 | - helper mod.to_s.classify.constantize | ||
356 | - else | ||
357 | - helper mod | ||
358 | - end | ||
359 | - end | ||
360 | - | ||
361 | end | 18 | end |
app/helpers/application_helper.rb
@@ -100,7 +100,7 @@ module ApplicationHelper | @@ -100,7 +100,7 @@ module ApplicationHelper | ||
100 | 100 | ||
101 | def link_to_myprofile(text, url = {}, profile = nil, options = {}) | 101 | def link_to_myprofile(text, url = {}, profile = nil, options = {}) |
102 | profile ||= current_user.login | 102 | profile ||= current_user.login |
103 | - link_to text, { :profile => profile }.merge(url), options | 103 | + link_to text, { :profile => profile, :controller => 'profile_editor' }.merge(url), options |
104 | end | 104 | end |
105 | 105 | ||
106 | def link_to_document(doc, text = nil) | 106 | def link_to_document(doc, text = nil) |
@@ -114,7 +114,7 @@ module ApplicationHelper | @@ -114,7 +114,7 @@ module ApplicationHelper | ||
114 | # TODO: test this helper | 114 | # TODO: test this helper |
115 | def user_links | 115 | def user_links |
116 | links = [ | 116 | links = [ |
117 | - ( link_to_homepage( _('My account') )), | 117 | + ( link_to_myprofile( _('My profile') )), |
118 | ( link_to_myprofile _('My Enterprises'), {:controller => 'membership_editor'} ), | 118 | ( link_to_myprofile _('My Enterprises'), {:controller => 'membership_editor'} ), |
119 | ( link_to(_('Admin'), { :controller => 'admin_panel' }) if current_user.person.is_admin?), | 119 | ( link_to(_('Admin'), { :controller => 'admin_panel' }) if current_user.person.is_admin?), |
120 | ].join("\n") | 120 | ].join("\n") |
@@ -124,7 +124,7 @@ module ApplicationHelper | @@ -124,7 +124,7 @@ module ApplicationHelper | ||
124 | def shortcut_header_links | 124 | def shortcut_header_links |
125 | if logged_in? | 125 | if logged_in? |
126 | [ | 126 | [ |
127 | - ( link_to_homepage( content_tag('span', _('My account')),nil, { :id => 'icon_go_home'} ) ), | 127 | + ( link_to_myprofile( content_tag('span', _('My profile')), {}, nil, { :id => 'icon_go_home'} ) ), |
128 | # MUDAR, O ID acima deve ser no Link <a id=... | 128 | # MUDAR, O ID acima deve ser no Link <a id=... |
129 | # O ID icon_accessibility tambem tem que aparcer e testei o link nao ta funcionado. | 129 | # O ID icon_accessibility tambem tem que aparcer e testei o link nao ta funcionado. |
130 | ( link_to content_tag('span', _('Admin')), { :controller => 'admin_panel' }, :id => 'icon_admin' if current_user.person.is_admin?), | 130 | ( link_to content_tag('span', _('Admin')), { :controller => 'admin_panel' }, :id => 'icon_admin' if current_user.person.is_admin?), |
@@ -303,16 +303,6 @@ module ApplicationHelper | @@ -303,16 +303,6 @@ module ApplicationHelper | ||
303 | end | 303 | end |
304 | end | 304 | end |
305 | 305 | ||
306 | - def select_filter_type(object, method, html_options) | ||
307 | - options = [ | ||
308 | - [ _('No Filter at all'), '[No Filter]' ], | ||
309 | - [ _('RDoc filter'), 'RDoc' ], | ||
310 | - [ _('Simple'), 'Simple' ], | ||
311 | - [ _('Textile'), 'Textile' ] | ||
312 | - ] | ||
313 | - select_tag "#{object}[#{method}]", options_for_select(options, @page.filter_type || Comatose.config.default_filter), { :id=> "#{object}_#{method}" }.merge(html_options) | ||
314 | - end | ||
315 | - | ||
316 | def file_manager(&block) | 306 | def file_manager(&block) |
317 | concat(content_tag('div', capture(&block), :class => 'file-manager') + "<br style='clear: left;'/>", block.binding) | 307 | concat(content_tag('div', capture(&block), :class => 'file-manager') + "<br style='clear: left;'/>", block.binding) |
318 | end | 308 | end |
app/helpers/cms_helper.rb
1 | module CmsHelper | 1 | module CmsHelper |
2 | 2 | ||
3 | - ########################################################### | ||
4 | - # content below was copied from comoatose | ||
5 | - ########################################################### | ||
6 | - | ||
7 | - # Checks the hidden_meta_fields class variable for a specified field name... | ||
8 | - def show_field?(key) | ||
9 | - !Comatose.config.hidden_meta_fields.include? key | ||
10 | - end | ||
11 | - | ||
12 | - # Used in the Page Form to build an indented drop-down list of pages | ||
13 | - def tree_select_box(nodes, selected= nil, hide= nil, label="Parent", add_initial=false) | ||
14 | - level = 0 | ||
15 | - select_box = add_initial ? "<option value=0>No #{label}</option>\n" : "" | ||
16 | - selected = nodes[0].id if selected.nil? and not add_initial | ||
17 | - nodes.each {|node| select_box += add_select_tree_node(node, selected, level, hide) } | ||
18 | - select_box += '' | ||
19 | - end | ||
20 | - # Called by tree_select_box | ||
21 | - def add_select_tree_node(node, selected, level, hide) | ||
22 | - padding = " " * level * 4 | ||
23 | - padding += '» ' unless level==0 | ||
24 | - hide_values = Array.new | ||
25 | - hide_values << hide if hide | ||
26 | - if node.id == selected | ||
27 | - select_box = %Q|<option value="#{node.id}" selected="true">#{padding}#{node.title}</option>\n| | ||
28 | - else | ||
29 | - if hide_values.include?(node.id) | ||
30 | - select_box = '' | ||
31 | - else | ||
32 | - select_box = %Q|<option value="#{node.id}">#{padding}#{node.title}</option>\n| | ||
33 | - end | ||
34 | - end | ||
35 | - node.children.each do |child| | ||
36 | - select_box += add_select_tree_node(child, selected, level + 1, hide) unless hide_values.include?(node.id) | ||
37 | - end | ||
38 | - select_box | ||
39 | - end | ||
40 | - | ||
41 | end | 3 | end |
app/helpers/document_helper.rb
@@ -7,7 +7,7 @@ module DocumentHelper | @@ -7,7 +7,7 @@ module DocumentHelper | ||
7 | def icon_for_document(doc) | 7 | def icon_for_document(doc) |
8 | icon = | 8 | icon = |
9 | case doc | 9 | case doc |
10 | - when Comatose::Page | 10 | + when Article |
11 | 'text-x-generic' | 11 | 'text-x-generic' |
12 | else | 12 | else |
13 | if doc.class.respond_to?(:icon) | 13 | if doc.class.respond_to?(:icon) |
app/models/article.rb
1 | -class Article < Comatose::Page | 1 | +class Article |
2 | + | ||
2 | acts_as_taggable | 3 | acts_as_taggable |
3 | 4 | ||
4 | # acts_as_ferret :fields => [:title, :body] | 5 | # acts_as_ferret :fields => [:title, :body] |
@@ -19,12 +20,6 @@ class Article < Comatose::Page | @@ -19,12 +20,6 @@ class Article < Comatose::Page | ||
19 | @profile ||= Profile.find_by_identifier(self.full_path.split(/\//).first) | 20 | @profile ||= Profile.find_by_identifier(self.full_path.split(/\//).first) |
20 | end | 21 | end |
21 | 22 | ||
22 | - def title=(value) | ||
23 | - super | ||
24 | - # taken from comatose, added a call to transliterate right before downcase. | ||
25 | - if (self[:slug].nil? or self[:slug].empty?) and !self[:title].nil? | ||
26 | - self[:slug] = self[:title].transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s | ||
27 | - end | ||
28 | - end | 23 | + # FIXME add code from Category to make article acts as a "file system" |
29 | 24 | ||
30 | end | 25 | end |
app/models/category.rb
@@ -72,6 +72,8 @@ class Category < ActiveRecord::Base | @@ -72,6 +72,8 @@ class Category < ActiveRecord::Base | ||
72 | 72 | ||
73 | self[:name] = value | 73 | self[:name] = value |
74 | unless self.name.blank? | 74 | unless self.name.blank? |
75 | + # FIXME encapsulate this patter (transliterate -> downcase -> gsub ...) | ||
76 | + # in a String method, say, to_slug | ||
75 | self.slug = self.name.transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s | 77 | self.slug = self.name.transliterate.downcase.gsub( /[^-a-z0-9~\s\.:;+=_]/, '').gsub(/[\s\.:;=_+]+/, '-').gsub(/[\-]{2,}/, '-').to_s |
76 | end | 78 | end |
77 | end | 79 | end |
app/models/profile.rb
@@ -11,19 +11,6 @@ class Profile < ActiveRecord::Base | @@ -11,19 +11,6 @@ class Profile < ActiveRecord::Base | ||
11 | 'edit_profile_design' => N_('Edit profile design'), | 11 | 'edit_profile_design' => N_('Edit profile design'), |
12 | } | 12 | } |
13 | 13 | ||
14 | - after_create do |profile| | ||
15 | - homepage = Article.new | ||
16 | - homepage.title = profile.name | ||
17 | - homepage.parent = Comatose::Page.root | ||
18 | - homepage.slug = profile.identifier | ||
19 | - homepage.save! | ||
20 | - end | ||
21 | - | ||
22 | - after_destroy do |profile| | ||
23 | - article = Article.find_by_path(profile.identifier) | ||
24 | - article.destroy if article | ||
25 | - end | ||
26 | - | ||
27 | acts_as_accessible | 14 | acts_as_accessible |
28 | 15 | ||
29 | acts_as_design | 16 | acts_as_design |
@@ -84,8 +71,8 @@ class Profile < ActiveRecord::Base | @@ -84,8 +71,8 @@ class Profile < ActiveRecord::Base | ||
84 | end | 71 | end |
85 | 72 | ||
86 | def homepage(reload = false) | 73 | def homepage(reload = false) |
87 | - @homepage = nil if reload | ||
88 | - @homepage ||= Article.find_by_path(self.identifier) | 74 | + # FIXME |
75 | + raise 'needs to be implemented' | ||
89 | end | 76 | end |
90 | 77 | ||
91 | # Returns information about the profile's owner that was made public by | 78 | # Returns information about the profile's owner that was made public by |
app/views/cms/_form.rhtml
@@ -1,106 +0,0 @@ | @@ -1,106 +0,0 @@ | ||
1 | - | ||
2 | -<%= javascript_include_tag 'tiny_mce/tiny_mce.js' %> | ||
3 | -<%= javascript_include_tag 'noosfero_tiny_mce.js' %> | ||
4 | -<script> | ||
5 | -tinyMCE.init({ | ||
6 | - mode : "textareas", | ||
7 | - theme : "advanced", | ||
8 | - theme_advanced_toolbar_location : "top", | ||
9 | - theme_advanced_layout_manager: 'SimpleLayout', | ||
10 | - theme_advanced_buttons1 : "bold,italic,underline,strikethrough,separator,undo,redo,separator,formatselect,separator,bullist,numlist,separator,justifyleft,justifycenter,justifyright,justifyfull,separator,link,unlink,image,table,separator,cleanup,code,separator,help", | ||
11 | - theme_advanced_buttons2 : "", | ||
12 | - theme_advanced_buttons3 : "", | ||
13 | - apply_source_formatting : true, | ||
14 | - language: <%= language.inspect %>, | ||
15 | -}); | ||
16 | -</script> | ||
17 | - | ||
18 | - | ||
19 | - | ||
20 | - | ||
21 | -<%= error_messages_for :page %> | ||
22 | - | ||
23 | -<% form_for :page, @page do |f| %> | ||
24 | - | ||
25 | - <div class='comatose_field'> | ||
26 | - <label for="page_title"><%= _("Title") %></label> | ||
27 | - <%= f.text_field :title, :tabindex => 1, :maxlength => 255, :size => 30 %> <%= link_to_function _("More..."), "ComatoseEditForm.toggle_extra_fields(this, '%s', '%s')" % [_('More...'), _('Less...')], :id => 'more-options' %> | ||
28 | - </div> | ||
29 | - | ||
30 | - <div class='comatose_field' id='slug_row'> | ||
31 | - <label for="page_slug"><%= _('Slug') %></label> | ||
32 | - <%= f.text_field :slug, :tabindex=>6, :maxlength=>255, :size=>50, :disabled=>@root_pages.include?(@page) %> | ||
33 | - </div> | ||
34 | - | ||
35 | - <div class='comatose_field' id='keywords_row'> | ||
36 | - <% if show_field? 'keywords' %> | ||
37 | - <label for="page_keywords"><%= _('Keywords') %></label> | ||
38 | - <%= f.text_field :keywords, :tabindex=>7, :maxlength=>1000, :size=>50 %> | ||
39 | - <% end %> | ||
40 | - </div> | ||
41 | - | ||
42 | - <div class='comatose_field' id='parent_row'> | ||
43 | - <% if show_field? 'parent' %> | ||
44 | - <label for="page_parent"><%= _('Parent') %></label> | ||
45 | - <% if mode != :new and @root_pages.include? @page %> | ||
46 | - <select id="page_parent" disabled="true"><option><%= _('%s is a root page') % @page.title %></option></select> | ||
47 | - <% else %> | ||
48 | - <select id="page_parent" name="page[parent_id]" tabindex="8"><%= tree_select_box @root_pages, @page.parent_id, @page.id %></select> | ||
49 | - <% end %> | ||
50 | - <% end %> | ||
51 | - </div> | ||
52 | - | ||
53 | - <div class='comatose_field'> | ||
54 | - <label for="page_body"><%= _('Content') %></label> | ||
55 | - <%= text_editor('page', 'body', 'filter_type', :tabindex => 2) %> | ||
56 | - </div> | ||
57 | - | ||
58 | - <div class='comatose_field' id='filter_row'> | ||
59 | - <% if show_field? 'filter' %> | ||
60 | - <label for="page_filter_type"><%= _("Filter") %></label> | ||
61 | - <%= select_filter_type('page', 'filter_type', :tabindex => 3 ) %> | ||
62 | - <span class="field-help"><%= _('Converts plain text into HTML') %></span> | ||
63 | - <% end %> | ||
64 | - </div> | ||
65 | - | ||
66 | - <div class='comatose_field' id='created_row'> | ||
67 | - <% if show_field? 'created_on' %> | ||
68 | - <label for="page_created_on"><%= _('Created') %></label> | ||
69 | - <%= f.datetime_select :created_on %> | ||
70 | - <% end %> | ||
71 | - </div> | ||
72 | - | ||
73 | -<div id="button-group"> | ||
74 | -<% unless @page.updated_on.nil? %> | ||
75 | - <div class="last-update"> | ||
76 | - <label> | ||
77 | - <%= link_to(n_("One revision", "%d revisions", @page.versions.length) % @page.versions.length, :action=>'versions', :id=>@page) if @page.versions.length > 0 %> | ||
78 | - </label> | ||
79 | - </div> | ||
80 | -<% end %> | ||
81 | - | ||
82 | -<%= image_tag 'comatose/spinner.gif', :id=>'spinner', :align=>'absmiddle', :style=>'display:none;' %> | ||
83 | - <%= button_to_function('Preview', "ComatoseEditForm.preview_content('#{url_for :controller=>controller.controller_name, :action=>'preview', :id=>@page}', '%s')" % _('Loading preview ...'), :tabindex=>3, :id=>'preview-btn' ) if show_field? 'preview' %> | ||
84 | - <%= submit_tag ((mode == :edit) ? _('Save Changes') : _('Create Page')), :tabindex=>4 %> | ||
85 | - <% if @page.versions.length > 0 %> | ||
86 | - <%= link_to _("Revert"), :action=>'versions', :id=>@page %> | ||
87 | - <% end %> | ||
88 | - or | ||
89 | - <a href="<%= url_for :controller=>controller.controller_name, :action=>'index' %>" onlick="ComatoseEditForm.cancel(this.href, '<%= _('Changes detected. You will lose all the updates you have made if you proceed...') %>'); return false;" tabindex="5"><%= _("Cancel") %></a> | ||
90 | -</div> | ||
91 | -<% end %> | ||
92 | - | ||
93 | -<div id="preview-area" style='display: none;'> | ||
94 | - <fieldset> | ||
95 | - <legend><%= _('Page Preview') %></legend> | ||
96 | - <div class="preview-body"> | ||
97 | - <div id="preview-panel"><span style='color:blue;'><%= _('Loading Preview...') %></span></div> | ||
98 | - <div style="clear:both"></div> | ||
99 | - </div> | ||
100 | - </fieldset> | ||
101 | - <div class="commands"> | ||
102 | - <a href="#" onclick="$('preview-area').hide();"><%= _("Close Preview") %></a><% _("or") %><a href="#"><%= _('Back to top') %></a> | ||
103 | - </div> | ||
104 | -</div> | ||
105 | - | ||
106 | -<%= javascript_tag "ComatoseEditForm.init('#{mode.to_s}');" %> |
app/views/cms/_page_list_item.rhtml
@@ -1,57 +0,0 @@ | @@ -1,57 +0,0 @@ | ||
1 | -<%# Params: | ||
2 | -# - page (Page Node) | ||
3 | -# - level (integer indicating current tree depth) | ||
4 | -# Called From: | ||
5 | -# - index | ||
6 | -# Description: | ||
7 | -# This partial is used recursively. Render it with the root node, and it will recurse | ||
8 | -# down all of the child nodes to build a list with proper indentation to indicate | ||
9 | -# tree depth. | ||
10 | -%> | ||
11 | - | ||
12 | -<% | ||
13 | -# Create the page-level links... | ||
14 | -links = [] | ||
15 | -links << link_to((page.versions.length == 1 ? _('%d revision') : _('%d revisions')) % page.versions.length, :action=>'versions', :id=>page) if page.versions.length > 0 | ||
16 | -links << link_to(_('add child document'), {:action=>'new', :parent=>page}, :title=> _("Add a child to '%s'") % page.title, :class=>'add-page') | ||
17 | -links << link_to_function(_('reorder children'), "ComatoseList.toggle_reorder('page_list_#{page.id}',this,#{page.id}, '%s', '%s')" % [_('reorder children'), _('finished reordering')], :title=> _("Reorder children of '%s'") % page.title, :class=>'reorder-children', :href=>url_for(:action=>'reorder', :id=>page)) if !page.children.empty? and page.children.length > 1 | ||
18 | -links << link_to(_('delete'), {:action=>'delete', :id=>page}, :confirm=> _('This will delete this page, and any children. Are you sure?'), :title=> _("Delete page '%s' and all it's children") % page.title, :class=>'delete-page', :method=>'post', :onmouseover=>"ComatoseList.item_hover('page_#{page.id}', 'over', true)", :onmouseout=>"ComatoseList.item_hover('page_#{page.id}', 'out', true)") unless @root_pages.include? page | ||
19 | -# Level check, one, two, three... | ||
20 | -collapse_children = (level >= Comatose.config.default_tree_level) | ||
21 | -%> | ||
22 | - | ||
23 | -<li id="page_<%= page.id %>"> | ||
24 | - <table cellpadding="0" cellspacing="0"> | ||
25 | - <tr> | ||
26 | - <td valign="center"> | ||
27 | - <% if !page.children.empty? %> | ||
28 | - <%= image_tag( ((collapse_children) ? 'comatose/collapsed.gif' : 'comatose/expanded.gif'), :title=>'Expand/Collapse', :onclick=>"ComatoseList.toggle_tree_nodes(this,#{page.id});", :class=>'tree-controller', :size=>'12x12', :id=>"page_controller_#{page.id}" ) %> | ||
29 | - <% else %> | ||
30 | - <%= image_tag 'comatose/no-children.gif', :size=>'12x12', :class=>'tree-controller' %> | ||
31 | - <% end %> | ||
32 | - </td> | ||
33 | - <td valign="center"> | ||
34 | - <%= icon_for_document(page) %> | ||
35 | - <span class="handle"><%= _('DRAG') %></span> | ||
36 | - </td> | ||
37 | - <td> | ||
38 | - <%= link_to page.title, {:action=>'edit', :id=>page}, :title=>"Path:#{page.full_path}", :class=>'page' %> | ||
39 | - </td> | ||
40 | - <td class="commands"> | ||
41 | - <%= links.join(', ') %>. | ||
42 | - </td> | ||
43 | - </tr> | ||
44 | - </table> | ||
45 | - | ||
46 | - <ul id="page_list_<%= page.id %>" old="lvl-<%= page.id %>" class="page-list <%= 'collapsed' if collapse_children %>" > | ||
47 | - <% for child in page.children %> | ||
48 | - <%= render :partial=>'page_list_item', :locals=>{ :page=>child, :level=>level+1 } %> | ||
49 | - <% end %> | ||
50 | - </ul> | ||
51 | - | ||
52 | - <%= sortable_element( "page_list_#{page.id}", | ||
53 | - :complete => visual_effect(:highlight, "page_list_#{page.id}"), | ||
54 | - :handle=>'handle', | ||
55 | - :update=>'flash-content', | ||
56 | - :url => { :action => "reorder", :id=>page } ) if !page.children.empty? and page.children.length > 1 %> | ||
57 | -</li> |
app/views/cms/delete.rhtml
@@ -1,18 +0,0 @@ | @@ -1,18 +0,0 @@ | ||
1 | -<h1> | ||
2 | - Page Delete Confirmation | ||
3 | -</h1> | ||
4 | - | ||
5 | -<blockquote> | ||
6 | - <p><%= _('Are you sure you want to delete the page titled "%s"?') % content_tag('strong', @page.title) %> </p> | ||
7 | - <% unless @page.children.empty? %> | ||
8 | - <p><%= _("It has %s child pages that will also be deleted...") % content_tag('strong', @page.children.length) %></p> | ||
9 | -<% end %> | ||
10 | -</blockquote> | ||
11 | - | ||
12 | -<%= start_form_tag %> | ||
13 | -<div id="button-group"> | ||
14 | - <%= submit_tag _("Yes, Delete The Page") %> | ||
15 | - or | ||
16 | - <%= link_to _("Cancel"), :action=>'index' %> | ||
17 | -</div> | ||
18 | -<%= end_form_tag %> |
app/views/cms/edit.rhtml
app/views/cms/index.rhtml
@@ -1,22 +0,0 @@ | @@ -1,22 +0,0 @@ | ||
1 | -<div class="action"> | ||
2 | - <%= link_to _('Clear Page Cache'), :controller=>controller.controller_name, :action=>'expire_page_cache' %> | ||
3 | -</div> | ||
4 | - | ||
5 | -<h1> | ||
6 | - <%= _('Articles') %> | ||
7 | - <%= image_tag 'comatose/spinner.gif', :id=>'spinner', :align=>'absmiddle', :style=>'display:none;' %> | ||
8 | -</h1> | ||
9 | - | ||
10 | -<ul class="page-list root"> | ||
11 | -<% @root_pages.each do |page| %> | ||
12 | - <%= render :partial=>'page_list_item', :locals=>{ :page=>page, :level=>1 } %> | ||
13 | -<% end %> | ||
14 | -</ul> | ||
15 | - | ||
16 | -<div> | ||
17 | - <%= link_to _('New article'), :action => 'new' %> | ||
18 | -</div> | ||
19 | - | ||
20 | -<div id="status"></div> | ||
21 | - | ||
22 | -<%= javascript_tag "ComatoseList.init()" %> |
app/views/cms/new.rhtml
app/views/cms/reorder.rhtml
@@ -1,30 +0,0 @@ | @@ -1,30 +0,0 @@ | ||
1 | -<h1><%= _('Reorder Pages') %></h1> | ||
2 | - | ||
3 | -<h3><%= _('"%s" child pages:') % @page.title %></h3> | ||
4 | - | ||
5 | -<ul class="page-list"> | ||
6 | -<% @page.children.each do |page| %> | ||
7 | - <li> | ||
8 | - <table cellpadding="0" cellspacing="0"> | ||
9 | - <tr> | ||
10 | - <td rowspan="2" valign="center"> | ||
11 | - <%= image_tag 'comatose/page.gif', :size=>'25x31', :align=>"absmiddle" %> | ||
12 | - </td> | ||
13 | - <td> | ||
14 | - <a class="page"><%= page.title %></a> | ||
15 | - </td> | ||
16 | - </tr> | ||
17 | - <tr> | ||
18 | - <td class="commands"> | ||
19 | - <%= link_to _("Move Up"), :action=>'reorder', :cmd=>'up', :page=>page.id %>, | ||
20 | - <%= link_to _("Move Down"), :action=>'reorder', :cmd=>'down', :page=>page.id %> | ||
21 | - </td> | ||
22 | - </tr> | ||
23 | - </table> | ||
24 | - </li> | ||
25 | -<% end %> | ||
26 | -</ul> | ||
27 | - | ||
28 | -<div id="button-group"> | ||
29 | - <%= link_to _("Finished"), :action=>'index' %> | ||
30 | -</div> |
app/views/cms/versions.rhtml
@@ -1,44 +0,0 @@ | @@ -1,44 +0,0 @@ | ||
1 | -<h1><%= _('Page Revisions') %></h1> | ||
2 | -<form> | ||
3 | -<div class="revisions older-content"> | ||
4 | - <div class="header"> | ||
5 | - <div class="header-actions"> | ||
6 | - <% form_tag :action => 'versions', :id => @page, :html => { :method => :get } do %> | ||
7 | - <%= _('View Version:') %><%= select_tag "version", options_from_collection_for_select(@page.versions, 'version', 'version', @version_num), {'onchange'=>'this.form.submit();'} %> | ||
8 | - <%= submit_tag 'Go', {'id'=>'go-btn'} %> | ||
9 | - <% end %> | ||
10 | - </div> | ||
11 | - <%= _('Version %s') % @version_num %> | ||
12 | - </div> | ||
13 | - <div class="meta"> | ||
14 | - <label class="title"><span><%= _('Title:') %></span><%= @version.title %></label> | ||
15 | - <label><span><%= _('Slug:') %></span> <%= @version.slug %></label> | ||
16 | - <% if show_field? 'keywords' %> | ||
17 | - <label><span><%= _("Keywords:") %></span> <%= @version.keywords %></label> | ||
18 | - <% end %> | ||
19 | - </div> | ||
20 | - <%= @version.body.split("\n").join('<br/>') unless @version.body.nil? %> | ||
21 | - <div id="button-group" class="footer"> | ||
22 | - <% form_tag :action=>'set_version', :id => @page, :version => @version_num do %> | ||
23 | - <%= submit_tag _("Set As Current Version") %> | ||
24 | - <%= _('or') %> | ||
25 | - <%= link_to _("Cancel"), :action=>'index' %> | ||
26 | - <% end %> | ||
27 | - </div> | ||
28 | -</div> | ||
29 | - | ||
30 | -<div class="revisions current-content"> | ||
31 | - <div class="header"> | ||
32 | - <% _('Current Version') %> | ||
33 | - </div> | ||
34 | - <div class="meta"> | ||
35 | - <label class="title"><span><%= _('Title:') %></span><%= @page.title %></label> | ||
36 | - <label><span><%= _('Slug:') %></span> <%= @page.slug %></label> | ||
37 | - <% if show_field? 'keywords' %> | ||
38 | - <label><span><%= _('Keywords:') %></span> <%= @page.keywords %></label> | ||
39 | - <% end %> | ||
40 | - </div> | ||
41 | - <%= @page.body.split("\n").join('<br/>') unless @page.body.nil? %> | ||
42 | -</div> | ||
43 | - | ||
44 | -<div style="clear:both"> </div> |
app/views/layouts/application.rhtml
@@ -67,7 +67,6 @@ | @@ -67,7 +67,6 @@ | ||
67 | </div><!-- id='header' --> | 67 | </div><!-- id='header' --> |
68 | <div id='content'> | 68 | <div id='content'> |
69 | <!-- <a name='main_content'/></a> --> | 69 | <!-- <a name='main_content'/></a> --> |
70 | - <!-- Aqui entra um conteudo tipo o titulo da pagina do usuário e os botoes do comatose? --> | ||
71 | <div id='header_content'> | 70 | <div id='header_content'> |
72 | </div> | 71 | </div> |
73 | 72 |
config/environment.rb
@@ -75,30 +75,5 @@ Localist.callback = lambda { |l| GetText.locale= l } | @@ -75,30 +75,5 @@ Localist.callback = lambda { |l| GetText.locale= l } | ||
75 | 75 | ||
76 | Tag.hierarchical = true | 76 | Tag.hierarchical = true |
77 | 77 | ||
78 | -Comatose.configure do |config| | ||
79 | - config.admin_get_root_page do | ||
80 | - Comatose::Page.find_by_path(request.parameters[:profile]) | ||
81 | - end | ||
82 | - config.admin_authorization do |config| | ||
83 | - Profile.exists?(:identifier => request.parameters[:profile]) | ||
84 | - # FIXME: also check permissions | ||
85 | - end | ||
86 | - | ||
87 | - config.default_filter = '[No Filter]' | ||
88 | -end | ||
89 | -#Comatose::AdminController.design :holder => 'environment' | ||
90 | -Comatose::AdminController.before_filter do |controller| | ||
91 | - # TODO: copy/paste; extract this into a method (see | ||
92 | - # app/controllers/application.rb) | ||
93 | - domain = Domain.find_by_name(controller.request.host) | ||
94 | - if domain.nil? | ||
95 | - environment = Environment.default | ||
96 | - else | ||
97 | - environment = domain.environment | ||
98 | - profile = domain.profile | ||
99 | - end | ||
100 | - controller.instance_variable_set('@environment', environment) | ||
101 | -end | ||
102 | - | ||
103 | # string transliteration | 78 | # string transliteration |
104 | require 'noosfero/transliterations' | 79 | require 'noosfero/transliterations' |
db/migrate/007_add_comatose_support.rb
@@ -1,40 +0,0 @@ | @@ -1,40 +0,0 @@ | ||
1 | -module Comatose | ||
2 | - class Page < ActiveRecord::Base | ||
3 | - set_table_name 'comatose_pages' | ||
4 | - acts_as_versioned :if_changed => [:title, :slug, :keywords, :body] | ||
5 | - end | ||
6 | -end | ||
7 | - | ||
8 | -class AddComatoseSupport < ActiveRecord::Migration | ||
9 | - | ||
10 | - # Schema for Comatose version 0.7+ | ||
11 | - def self.up | ||
12 | - create_table :comatose_pages do |t| | ||
13 | - t.column "parent_id", :integer | ||
14 | - t.column "full_path", :text, :default => '' | ||
15 | - t.column "title", :string, :limit => 255 | ||
16 | - t.column "slug", :string, :limit => 255 | ||
17 | - t.column "keywords", :string, :limit => 255 | ||
18 | - t.column "body", :text | ||
19 | - t.column "filter_type", :string, :limit => 25, :default => "[No Filter]" | ||
20 | - t.column "author", :string, :limit => 255 | ||
21 | - t.column "position", :integer, :default => 0 | ||
22 | - t.column "version", :integer | ||
23 | - t.column "updated_on", :datetime | ||
24 | - t.column "created_on", :datetime | ||
25 | - | ||
26 | - # added for STI in noosfero | ||
27 | - t.column 'type', :string | ||
28 | - | ||
29 | - end | ||
30 | - Comatose::Page.create_versioned_table | ||
31 | - puts "Creating the default 'Home Page'..." | ||
32 | - Comatose::Page.create!( :title=>'Home Page', :body=>"h1. Welcome\n\nYour content goes here...", :author=>'System' ) | ||
33 | - end | ||
34 | - | ||
35 | - def self.down | ||
36 | - Comatose::Page.drop_versioned_table | ||
37 | - drop_table :comatose_pages | ||
38 | - end | ||
39 | - | ||
40 | -end |
test/functional/content_viewer_controller_test.rb
@@ -6,8 +6,8 @@ class ContentViewerController; def rescue_action(e) raise e end; end | @@ -6,8 +6,8 @@ class ContentViewerController; def rescue_action(e) raise e end; end | ||
6 | 6 | ||
7 | class ContentViewerControllerTest < Test::Unit::TestCase | 7 | class ContentViewerControllerTest < Test::Unit::TestCase |
8 | 8 | ||
9 | -# all_fixtures:domains, :environments, :users, :profiles, :comatose_pages | ||
10 | -all_fixtures | 9 | + all_fixtures |
10 | + | ||
11 | def setup | 11 | def setup |
12 | @controller = ContentViewerController.new | 12 | @controller = ContentViewerController.new |
13 | @request = ActionController::TestRequest.new | 13 | @request = ActionController::TestRequest.new |
test/integration/editing_person_info_test.rb
@@ -2,7 +2,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" | @@ -2,7 +2,7 @@ require "#{File.dirname(__FILE__)}/../test_helper" | ||
2 | 2 | ||
3 | class EditingPersonInfoTest < ActionController::IntegrationTest | 3 | class EditingPersonInfoTest < ActionController::IntegrationTest |
4 | 4 | ||
5 | - fixtures :users, :profiles, :comatose_pages, :domains, :environments, :person_infos | 5 | + fixtures :users, :profiles, :domains, :environments, :person_infos |
6 | 6 | ||
7 | should 'allow to edit person info' do | 7 | should 'allow to edit person info' do |
8 | 8 |
test/integration/manage_documents_test.rb
@@ -5,69 +5,18 @@ class ManageDocumentsTest < ActionController::IntegrationTest | @@ -5,69 +5,18 @@ class ManageDocumentsTest < ActionController::IntegrationTest | ||
5 | all_fixtures | 5 | all_fixtures |
6 | 6 | ||
7 | def test_creation_of_a_new_article | 7 | def test_creation_of_a_new_article |
8 | - count = Article.count | ||
9 | - | ||
10 | - login('ze', 'test') | ||
11 | - | ||
12 | - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms' } | ||
13 | - | ||
14 | - get '/myprofile/ze/cms' | ||
15 | - assert_response :success | ||
16 | - | ||
17 | - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/ze/cms/new' } | ||
18 | - get '/myprofile/ze/cms/new' | ||
19 | - assert_response :success | ||
20 | - assert_tag :tag => 'form', :attributes => { :action => '/myprofile/ze/cms/new' } | ||
21 | - | ||
22 | - post '/myprofile/ze/cms/new', :page => { :title => 'my new article', :body => 'this is the text of my new article' , :parent_id => Article.find_by_path('ze').id } | ||
23 | - assert_response :redirect | ||
24 | - | ||
25 | - follow_redirect! | ||
26 | - assert_response :success | ||
27 | - assert_equal '/myprofile/ze/cms', path | ||
28 | - | ||
29 | - assert_equal count + 1, Article.count | ||
30 | - | 8 | + # FIXME |
9 | + fail 'need to be rewritten' | ||
31 | end | 10 | end |
32 | 11 | ||
33 | def test_update_of_an_existing_article | 12 | def test_update_of_an_existing_article |
34 | - login('ze', 'test') | ||
35 | - | ||
36 | - get '/myprofile/ze/cms' | ||
37 | - assert_response :success | ||
38 | - | ||
39 | - id = Comatose::Page.find_by_path('ze').id | ||
40 | - get "myprofile/ze/cms/edit/#{id}" | ||
41 | - assert_response :success | ||
42 | - assert_tag :tag => 'form', :attributes => { :action => "/myprofile/ze/cms/edit/#{id}" } | ||
43 | - | ||
44 | - post "myprofile/ze/cms/edit/#{id}", :page => { :body => 'changed_body' } | ||
45 | - assert_response :redirect | ||
46 | - follow_redirect! | ||
47 | - assert_equal '/myprofile/ze/cms', path | ||
48 | - | 13 | + # FIXME |
14 | + fail 'need to be rewritten' | ||
49 | end | 15 | end |
50 | 16 | ||
51 | def test_removing_an_article | 17 | def test_removing_an_article |
52 | - | ||
53 | - login('ze', 'test') | ||
54 | - | ||
55 | - article = Article.create!(:title => 'to be removed', :body => 'go to hell', :parent_id => Article.find_by_path('ze').id) | ||
56 | - | ||
57 | - get '/myprofile/ze/cms' | ||
58 | - assert_response :success | ||
59 | - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/ze/cms/delete/#{article.id}" } | ||
60 | - | ||
61 | - post "/myprofile/ze/cms/delete/#{article.id}" | ||
62 | - assert_response :redirect | ||
63 | - follow_redirect! | ||
64 | - assert_equal '/myprofile/ze/cms', path | ||
65 | - | ||
66 | - assert_raise ActiveRecord::RecordNotFound do | ||
67 | - Article.find(article.id) | ||
68 | - end | 18 | + # FIXME |
19 | + fail 'need to be rewritten' | ||
69 | end | 20 | end |
70 | 21 | ||
71 | - # FIXME: add tests for page reordering | ||
72 | - | ||
73 | end | 22 | end |
test/integration/routing_test.rb
@@ -30,7 +30,7 @@ class RoutingTest < ActionController::IntegrationTest | @@ -30,7 +30,7 @@ class RoutingTest < ActionController::IntegrationTest | ||
30 | assert_routing('/account/new_password/90dfhga7sadgd0as6saas', :controller => 'account', :action => 'new_password', :code => '90dfhga7sadgd0as6saas') | 30 | assert_routing('/account/new_password/90dfhga7sadgd0as6saas', :controller => 'account', :action => 'new_password', :code => '90dfhga7sadgd0as6saas') |
31 | end | 31 | end |
32 | 32 | ||
33 | - def test_comatose_admin | 33 | + def test_cms |
34 | assert_routing('/myprofile/ze/cms', :profile => 'ze', :controller => 'cms', :action => 'index') | 34 | assert_routing('/myprofile/ze/cms', :profile => 'ze', :controller => 'cms', :action => 'index') |
35 | end | 35 | end |
36 | 36 |
test/mocks/test/comatose_admin_controller.rb
test/unit/article_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | class ArticleTest < Test::Unit::TestCase | 3 | class ArticleTest < Test::Unit::TestCase |
4 | - fixtures :comatose_pages | ||
5 | 4 | ||
6 | def test_should_use_keywords_as_tags | 5 | def test_should_use_keywords_as_tags |
7 | article = Article.new | 6 | article = Article.new |
@@ -17,8 +16,8 @@ class ArticleTest < Test::Unit::TestCase | @@ -17,8 +16,8 @@ class ArticleTest < Test::Unit::TestCase | ||
17 | end | 16 | end |
18 | 17 | ||
19 | should 'have an associated profile' do | 18 | should 'have an associated profile' do |
19 | + # FIXME this is now wrong | ||
20 | article = Article.new(:title => 'someuser', :body => "some text") | 20 | article = Article.new(:title => 'someuser', :body => "some text") |
21 | - article.parent = Comatose::Page.root | ||
22 | article.save! | 21 | article.save! |
23 | 22 | ||
24 | Profile.expects(:find_by_identifier).with("someuser") | 23 | Profile.expects(:find_by_identifier).with("someuser") |
test/unit/enterprise_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | class EnterpriseTest < Test::Unit::TestCase | 3 | class EnterpriseTest < Test::Unit::TestCase |
4 | - fixtures :profiles, :environments, :users, :comatose_pages | 4 | + fixtures :profiles, :environments, :users |
5 | 5 | ||
6 | def test_identifier_validation | 6 | def test_identifier_validation |
7 | p = Enterprise.new | 7 | p = Enterprise.new |
test/unit/person_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | class PersonTest < Test::Unit::TestCase | 3 | class PersonTest < Test::Unit::TestCase |
4 | - fixtures :profiles, :users, :comatose_pages | 4 | + fixtures :profiles, :users |
5 | 5 | ||
6 | def test_person_must_come_form_the_cration_of_an_user | 6 | def test_person_must_come_form_the_cration_of_an_user |
7 | p = Person.new(:name => 'John', :identifier => 'john') | 7 | p = Person.new(:name => 'John', :identifier => 'john') |
test/unit/profile_test.rb
1 | require File.dirname(__FILE__) + '/../test_helper' | 1 | require File.dirname(__FILE__) + '/../test_helper' |
2 | 2 | ||
3 | class ProfileTest < Test::Unit::TestCase | 3 | class ProfileTest < Test::Unit::TestCase |
4 | - fixtures :profiles, :environments, :users, :comatose_pages | 4 | + fixtures :profiles, :environments, :users |
5 | 5 | ||
6 | def test_identifier_validation | 6 | def test_identifier_validation |
7 | p = Profile.new | 7 | p = Profile.new |
@@ -45,15 +45,7 @@ class ProfileTest < Test::Unit::TestCase | @@ -45,15 +45,7 @@ class ProfileTest < Test::Unit::TestCase | ||
45 | p.identifier = 'other_profile' | 45 | p.identifier = 'other_profile' |
46 | end | 46 | end |
47 | end | 47 | end |
48 | - | ||
49 | - # when a profile called a page named after it must also be created. | ||
50 | - def test_should_create_homepage_when_creating_profile | ||
51 | - Profile.create!(:identifier => 'newprofile', :name => 'New Profile') | ||
52 | - page = Comatose::Page.find_by_path('newprofile') | ||
53 | - assert_not_nil page | ||
54 | - assert_equal 'New Profile', page.title | ||
55 | - end | ||
56 | - | 48 | + |
57 | def test_should_provide_access_to_homepage | 49 | def test_should_provide_access_to_homepage |
58 | profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') | 50 | profile = Profile.create!(:identifier => 'newprofile', :name => 'New Profile') |
59 | page = profile.homepage | 51 | page = profile.homepage |
@@ -97,10 +89,7 @@ class ProfileTest < Test::Unit::TestCase | @@ -97,10 +89,7 @@ class ProfileTest < Test::Unit::TestCase | ||
97 | end | 89 | end |
98 | 90 | ||
99 | def test_should_remove_pages_when_removing_profile | 91 | def test_should_remove_pages_when_removing_profile |
100 | - profile = Profile.create(:name => 'To bee removed', :identifier => 'to_be_removed') | ||
101 | - assert Comatose::Page.find_by_path('to_be_removed') | ||
102 | - profile.destroy | ||
103 | - assert !Comatose::Page.find_by_path('to_be_removed') | 92 | + fail 'neet to be reimplemented' |
104 | end | 93 | end |
105 | 94 | ||
106 | def test_should_define_info | 95 | def test_should_define_info |
test/unit/user_test.rb
@@ -4,7 +4,7 @@ class UserTest < Test::Unit::TestCase | @@ -4,7 +4,7 @@ class UserTest < Test::Unit::TestCase | ||
4 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead. | 4 | # Be sure to include AuthenticatedTestHelper in test/test_helper.rb instead. |
5 | # Then, you can remove it from this and the functional test. | 5 | # Then, you can remove it from this and the functional test. |
6 | include AuthenticatedTestHelper | 6 | include AuthenticatedTestHelper |
7 | - fixtures :users, :comatose_pages | 7 | + fixtures :users |
8 | 8 | ||
9 | def test_should_create_user | 9 | def test_should_create_user |
10 | assert_difference User, :count do | 10 | assert_difference User, :count do |