Changeset 1185
- Timestamp:
- 2008-09-23 15:13:32 (4 months ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (4 diffs)
- trunk/app/controllers/main_controller.rb (deleted)
- trunk/app/helpers/application_helper.rb (modified) (3 diffs)
- trunk/app/models/site.rb (modified) (5 diffs)
- trunk/app/views/main (deleted)
- trunk/app/views/nodes/404.html (added)
- trunk/app/views/nodes/500.html (added)
- trunk/app/views/nodes/_gallery.rhtml (added)
- trunk/app/views/nodes/_list_nodes.rhtml (added)
- trunk/app/views/nodes/save.rhtml (deleted)
- trunk/app/views/sites/_li.erb (modified) (1 diff)
- trunk/config/environment.rb (modified) (1 diff)
- trunk/config/routes.rb (modified) (1 diff)
- trunk/config/zena.rb (modified) (1 diff)
- trunk/db/migrate/000_zena/044_remove_monolingual_site_option.rb (added)
- trunk/db/schema.rb (modified) (1 diff)
- trunk/lib/node_query.rb (modified) (1 diff)
- trunk/lib/parser/lib/rules/zena.rb (modified) (1 diff)
- trunk/test/functional/application_controller_test.rb (modified) (1 diff)
- trunk/test/functional/main_controller_test.rb (deleted)
- trunk/test/helpers/zena_parser/relations.yml (modified) (1 diff)
- trunk/test/sites/complex/sites.yml (modified) (1 diff)
- trunk/test/sites/ocean/sites.yml (modified) (1 diff)
- trunk/test/sites/zena/sites.yml (modified) (1 diff)
- trunk/test/unit/site_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r1184 r1185 54 54 # site not found 55 55 respond_to do |format| 56 format.html { render :file => "#{RAILS_ROOT}/app/views/ main/404.html", :status => '404 Not Found' }56 format.html { render :file => "#{RAILS_ROOT}/app/views/nodes/404.html", :status => '404 Not Found' } 57 57 format.all { render :nothing => true, :status => "404 Not Found" } 58 58 end … … 76 76 =end 77 77 respond_to do |format| 78 format.html { render :file => "#{RAILS_ROOT}/app/views/ main/500.html", :status => '500 Error' }78 format.html { render :file => "#{RAILS_ROOT}/app/views/nodes/500.html", :status => '500 Error' } 79 79 format.all { render :nothing => true, :status => "500 Error" } 80 80 end … … 656 656 # force the use of a cacheable path for the data, even when navigating in '/oo' 657 657 # FIXME: we could use 'node.version.lang' if most of the time the version is loaded. 658 zen_path(node, opts.merge(:format => node.c_ext, :prefix=> (current_site[:monolingual] ? '' : node.v_lang)))658 zen_path(node, opts.merge(:format => node.c_ext, :prefix=>node.v_lang)) 659 659 else 660 660 zen_path(node, opts.merge(:format => node.c_ext)) … … 721 721 def prefix 722 722 if visitor.is_anon? 723 if current_site[:monolingual] 724 '' 725 else 726 lang 727 end 723 lang 728 724 else 729 725 AUTHENTICATED_PREFIX trunk/app/helpers/application_helper.rb
r1177 r1185 540 540 end 541 541 542 render_to_string( :partial=>' main/gallery', :locals=>{:gallery=>images} )542 render_to_string( :partial=>'nodes/gallery', :locals=>{:gallery=>images} ) 543 543 end 544 544 … … 572 572 end 573 573 return '' unless docs 574 prefix + render_to_string( :partial=>' main/list_nodes', :locals=>{:docs=>docs}) + suffix574 prefix + render_to_string( :partial=>'nodes/list_nodes', :locals=>{:docs=>docs}) + suffix 575 575 end 576 576 … … 1244 1244 # show language selector 1245 1245 def lang_links(opts={}) 1246 if visitor.site[:monolingual] 1247 "" 1248 else 1249 if opts[:wrap] 1250 tag_in = "<#{opts[:wrap]}>" 1251 tag_out = "</#{opts[:wrap]}>" 1252 else 1253 tag_in = tag_out = '' 1254 end 1255 res = [] 1256 visitor.site.lang_list.each do |l| 1257 if l == lang 1258 if opts[:wrap] 1259 res << "<#{opts[:wrap]} class='on'>#{l}" + tag_out 1260 else 1261 res << "<em>#{l}</em>" 1262 end 1246 if opts[:wrap] 1247 tag_in = "<#{opts[:wrap]}>" 1248 tag_out = "</#{opts[:wrap]}>" 1249 else 1250 tag_in = tag_out = '' 1251 end 1252 res = [] 1253 visitor.site.lang_list.each do |l| 1254 if l == lang 1255 if opts[:wrap] 1256 res << "<#{opts[:wrap]} class='on'>#{l}" + tag_out 1263 1257 else 1264 if visitor.is_anon? && params[:prefix] 1265 res << tag_in + link_to(l, :overwrite_params => {:prefix => l}) + tag_out 1266 else 1267 res << tag_in + link_to(l, :overwrite_params => {:lang => l}) + tag_out 1268 end 1258 res << "<em>#{l}</em>" 1269 1259 end 1270 end 1271 res.join(opts[:join] || '') 1272 end 1260 else 1261 if visitor.is_anon? && params[:prefix] 1262 res << tag_in + link_to(l, :overwrite_params => {:prefix => l}) + tag_out 1263 else 1264 res << tag_in + link_to(l, :overwrite_params => {:lang => l}) + tag_out 1265 end 1266 end 1267 end 1268 res.join(opts[:join] || '') 1273 1269 end 1274 1270 trunk/app/models/site.rb
r1184 r1185 11 11 +name+:: Site name (used to display grouped information for cross sites users). 12 12 +authorize+:: If this is set to true a login is required: anonymous visitor will not be allowed to browse the site as there is no login/password for the 'anonymous user'. 13 +monolingual+:: Only use the +default_lang+. This will disable the language selection menu and will remove the language prefix from all urls.14 13 +allow_private+:: If set to true, users will be allowed to create private nodes (seen only by themselves). 15 14 +languages+:: A comma separated list of the languages used for the current site. Do not insert spaces in this list. 16 +default_lang+:: The default language of the site (or the unique language if +monolingual+ is true).15 +default_lang+:: The default language of the site. 17 16 =end 18 17 class Site < ActiveRecord::Base … … 20 19 validates_uniqueness_of :host 21 20 # we are using 'attr_protected' instead of attr_accessible because we have dynamic attributes 22 attr_protected *(column_names.map{|e| e.to_sym} - [:name, :languages, :default_lang, :authentication, : monolingual, :allow_private, :http_auth, :auto_publish, :redit_time])21 attr_protected *(column_names.map{|e| e.to_sym} - [:name, :languages, :default_lang, :authentication, :allow_private, :http_auth, :auto_publish, :redit_time]) 23 22 has_many :groups, :order => "name" 24 23 has_many :nodes … … 28 27 29 28 @@attributes_for_form = { 30 :bool => [:authentication, : monolingual, :allow_private, :http_auth, :auto_publish],29 :bool => [:authentication, :allow_private, :http_auth, :auto_publish], 31 30 :text => [:name, :languages, :default_lang], 32 31 } … … 40 39 :name => host.split('.').first, 41 40 :authentication => false, 42 :monolingual => false,43 41 :allow_private => false, 44 42 :auto_publish => true, … … 231 229 end 232 230 233 # Return true if the site is configured to use a single language234 def monolingual?235 self[:monolingual]236 end237 238 231 # Return true if the site is configured to allow private nodes 239 232 def allow_private? trunk/app/views/sites/_li.erb
r830 r1185 10 10 <td class='site_group' ><%= li.site_group.name %></td> 11 11 <td class='redit_time' ><%= li.redit_time %></td> 12 <td class='options'><%= [:authentication, :monolingual, :allow_private, :http_auth, :auto_publish].reject{|sym| !li[sym]}.map{|sym| _(sym.to_s)}.join(', ') %></td>12 <td class='options'><%= Site.attributes_for_form[:bool].reject{|sym| !li[sym]}.map{|sym| _(sym.to_s)}.join(', ') %></td> 13 13 </tr> trunk/config/environment.rb
r1121 r1185 12 12 require File.join(File.dirname(__FILE__), 'boot') 13 13 14 # Set ZENA_ENV14 # Load zena specific settings 15 15 require File.join(File.dirname(__FILE__), 'zena') 16 16 require File.join(File.dirname(__FILE__), 'version') trunk/config/routes.rb
r1094 r1185 60 60 map.resources :data_entries, :member => { :zafu => :get } 61 61 62 # FIXME monolingual63 64 #map.login 'login' , :controller=>'login', :action=>'login'65 #map.logout 'logout', :controller=>'login', :action=>'logout'66 #67 #map.not_found '404', :controller=>'main', :action=>'not_found'68 #69 #map.user_home "#{AUTHENTICATED_PREFIX}/home", :controller=>'user', :action=>'home', :prefix=>"#{AUTHENTICATED_PREFIX}"70 #71 #map.connect ':prefix', :controller => "main", :action=>'index', :prefix=>/^(#{AUTHENTICATED_PREFIX}|\w\w)$/72 #73 #map.connect 'data/:ext/:version_id/:filename', :controller=>'document', :action=>'data'74 #75 #map.search 'z/search', :controller=>'search', :action=>'find'76 #77 #if ZENA_ENV[:monolingual]78 # map.connect '', :controller => "main", :action=>'index'79 # map.default 'z/:controller/:action/:id'80 # map.site_tree ':prefix/site_tree/:id', :controller=>'main', :action=>'site_tree', :prefix=>"#{AUTHENTICATED_PREFIX}"81 # map.connect ":prefix/*path", :controller=>'main', :action=>'show', :prefix=>"#{AUTHENTICATED_PREFIX}"82 # map.default 'z/:controller/:action/:id'83 # map.site_tree 'site_tree/:id', :controller=>'main', :action=>'site_tree', :prefix=>''84 # map.connect '*path', :controller=>'main', :action=>'show', :prefix=>''85 #else86 # map.site_tree ':prefix/site_tree/:id', :controller=>'main', :action=>'site_tree', :prefix=>/^(#{AUTHENTICATED_PREFIX}|\w\w)$/87 # map.connect ':prefix/*path', :controller=>'main', :action=>'show', :prefix=>/^(#{AUTHENTICATED_PREFIX}|\w\w)$/88 # map.default 'z/:controller/:action/:id'89 # map.connect '*path', :controller=>'main', :action=>'show'90 #end91 ##92 ## # Allow downloading Web Service WSDL as a file with an extension93 ## # instead of a file named 'wsdl'94 ## map.connect ':controller/service.wsdl', :action => 'wsdl'95 ##96 ## # Install the default route as the lowest priority.97 98 # map.connect ':controller/:action/:id'99 100 62 # temporary routes... 101 63 map.connect 'discussions/:action/:id', :controller => 'discussions' 102 map.connect 'z/link/:action/:id', :controller => 'link'103 map.connect 'z/link/:action', :controller => 'link'104 map.redirect '/redirect', :controller => 'main', :action => 'redirect'105 64 106 65 # catch all 107 66 map.connect '*path', :controller => 'nodes', :action => 'catch_all' 108 67 end 109 =begin110 ActionController::Routing::Routes.draw do |map|111 map.resources :relations112 113 map.resources :links114 115 # Add your own custom routes here.116 # The priority is based upon order of creation: first created -> highest priority.117 118 # Here's a sample route:119 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'120 # Keep in mind you can assign values other than :controller and :action121 122 # You can have the root of your site routed by hooking up ''123 # -- just remember to delete public/index.html.124 125 end126 =endtrunk/config/zena.rb
r1177 r1185 22 22 puts "\n** WARNING: drb server not running. Upload progress will not work." 23 23 puts " * WARNING: you should start the drb server with 'lib/upload_progress_server.rb start'\n\n" 24 end25 26 27 # FIXME: Remove ZENA_ENV, not needed anymore28 ZENA_ENV = {29 :site_name => 'zena',30 :root_id => 1,31 :authorize => false,32 :translate_group => 2, # default = admin33 :monolingual => false,34 :languages => ['en', 'fr', 'es'],35 :calendar_langs => ["en", "fr"],36 :default_lang => 'en',37 # :news_collector_id => 24,38 # :menu_tag_id => 23,39 :pub_comments => false, # do not open a public discussion by default40 :allow_anonymous_comments => true,41 :moderate_anonymous_comments => true,42 43 :allow_private_nodes => false,44 :password_salt => "fish zen ho",45 :data_dir => "/var/www/zenadmin.org/data", # configure data directory for uploaded files46 :edit_help_id => 3,47 }48 if ENV["RAILS_ENV"] != "test"49 ZENA_ENV.freeze50 24 end 51 25 trunk/db/schema.rb
r1184 r1185 231 231 t.column "name", :string 232 232 t.column "authentication", :boolean 233 t.column "monolingual", :boolean234 233 t.column "allow_private", :boolean 235 234 t.column "languages", :string trunk/lib/node_query.rb
r1173 r1185 202 202 when 'l_' 203 203 key, function = parse_sql_function_in_field(field) 204 if key == 'l_status' || key == 'l_comment' 204 if key == 'l_status' || key == 'l_comment' || (key == 'l_id' && context == :order) 205 205 @errors_unless_safe_links ||= [] 206 @errors_unless_safe_links << "cannot use link field '#{key}' in this query" 206 @errors_unless_safe_links << "cannot use link field '#{key}' in this query" unless (key == 'l_id' && context == :order) 207 207 # ok 208 208 function ? "#{function}(#{table('links')}.#{key[2..-1]})" : "#{table('links')}.#{key[2..-1]}" trunk/lib/parser/lib/rules/zena.rb
r1182 r1185 1615 1615 def r_icon 1616 1616 if !@params[:in] && !@params[:where] && !@params[:from] && !@params[:find] 1617 finder, klass = build_finder_for(:first, 'icon', @params.merge(:or => 'image' ))1617 finder, klass = build_finder_for(:first, 'icon', @params.merge(:or => 'image', :order => 'l_id desc')) 1618 1618 return unless finder 1619 1619 return parser_error("invalid class (#{klass})") unless klass.ancestors.include?(Node) trunk/test/functional/application_controller_test.rb
r1050 r1185 134 134 end 135 135 136 def test_prefix137 bak = ZENA_ENV[:monolingual]138 ZENA_ENV[:monolingual] = false139 @controller.instance_variable_set(:@session, :lang=>'en')140 assert_equal 'en', @controller.send(:prefix)141 @controller.instance_variable_set(:@session, :lang=>'ru')142 assert_equal 'ru', @controller.send(:prefix)143 @controller.instance_variable_set(:@session, :user=>{:id=>4, :lang=>'en', :groups=>[1,2,3]})144 assert_equal AUTHENTICATED_PREFIX, @controller.send(:prefix)145 ZENA_ENV[:monolingual] = true146 @controller.instance_variable_set(:@session, :user=>nil)147 assert_equal '', @controller.send(:prefix)148 @controller.instance_variable_set(:@session, :user=>{:id=>4, :lang=>'en', :groups=>[1,2,3]})149 assert_equal AUTHENTICATED_PREFIX, @controller.send(:prefix)150 ZENA_ENV[:monolingual] = bak151 end152 153 136 def test_bad_session_user 154 137 @controller.instance_variable_set(:@session, :user=>999, :host=>'test.host') trunk/test/helpers/zena_parser/relations.yml
r1173 r1185 37 37 node: 'cleanWater' 38 38 src: "<r:icon do='[name]'/>" 39 tem: "/ORDER BY links.id DESC/" 39 40 res: "lake" 40 41 trunk/test/sites/complex/sites.yml
r1028 r1185 7 7 site_group: complex 8 8 authentication: yes 9 monolingual: no10 9 allow_private: no 11 10 auto_publish: yes trunk/test/sites/ocean/sites.yml
r1028 r1185 7 7 site_group: aqua 8 8 authentication: no 9 monolingual: no10 9 allow_private: no 11 10 auto_publish: no trunk/test/sites/zena/sites.yml
r1184 r1185 7 7 site_group: workers 8 8 authentication: no 9 monolingual: no10 9 allow_private: yes 11 10 auto_publish: no trunk/test/unit/site_test.rb
r1094 r1185 172 172 end 173 173 174 def test_monolingual175 site = sites(:zena)176 assert !site.monolingual?, "Multi lang site"177 site.monolingual = true178 assert site.save, "Can save"179 assert site.monolingual?, "Mono lang site"180 end181 182 174 def test_allow_private 183 175 site = sites(:zena)
