Changeset 1185

Show
Ignore:
Timestamp:
2008-09-23 15:13:32 (4 months ago)
Author:
gaspard
Message:

commit 167894872f3c023e527457ec541ed20b488c6889
Author: Gaspard Bucher <gaspard@teti.ch>

Cleanup (removed unused templates/files, removed 'monolingual' option as it is not supported and useless state:resolved tagged:wontfix, removed ZENA_ENV state:resolved) and fixed [icon] bug when the node contains an image (image selected instead of icon). There can be a priority set for the relationship by using 'l_id desc' order rule.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/application.rb

    r1184 r1185  
    5454        # site not found 
    5555        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' } 
    5757          format.all  { render :nothing => true, :status => "404 Not Found" } 
    5858        end 
     
    7676=end 
    7777      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' } 
    7979        format.all  { render :nothing => true, :status => "500 Error" } 
    8080      end 
     
    656656        # force the use of a cacheable path for the data, even when navigating in '/oo' 
    657657        # 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)) 
    659659      else   
    660660        zen_path(node, opts.merge(:format => node.c_ext)) 
     
    721721    def prefix 
    722722      if visitor.is_anon? 
    723         if current_site[:monolingual] 
    724           '' 
    725         else 
    726           lang 
    727         end 
     723        lang 
    728724      else 
    729725        AUTHENTICATED_PREFIX 
  • trunk/app/helpers/application_helper.rb

    r1177 r1185  
    540540    end 
    541541     
    542     render_to_string( :partial=>'main/gallery', :locals=>{:gallery=>images} ) 
     542    render_to_string( :partial=>'nodes/gallery', :locals=>{:gallery=>images} ) 
    543543  end 
    544544 
     
    572572    end 
    573573    return '' unless docs 
    574     prefix + render_to_string( :partial=>'main/list_nodes', :locals=>{:docs=>docs}) + suffix 
     574    prefix + render_to_string( :partial=>'nodes/list_nodes', :locals=>{:docs=>docs}) + suffix 
    575575  end 
    576576   
     
    12441244  # show language selector 
    12451245  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 
    12631257        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>" 
    12691259        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] || '') 
    12731269  end 
    12741270   
  • trunk/app/models/site.rb

    r1184 r1185  
    1111+name+::            Site name (used to display grouped information for cross sites users). 
    1212+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. 
    1413+allow_private+::   If set to true, users will be allowed to create private nodes (seen only by themselves). 
    1514+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
    1716=end 
    1817class Site < ActiveRecord::Base 
     
    2019  validates_uniqueness_of :host 
    2120  # 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]) 
    2322  has_many :groups, :order => "name" 
    2423  has_many :nodes 
     
    2827   
    2928  @@attributes_for_form = { 
    30     :bool => [:authentication, :monolingual, :allow_private, :http_auth, :auto_publish], 
     29    :bool => [:authentication, :allow_private, :http_auth, :auto_publish], 
    3130    :text => [:name, :languages, :default_lang], 
    3231  } 
     
    4039        :name            => host.split('.').first, 
    4140        :authentication  => false, 
    42         :monolingual     => false, 
    4341        :allow_private   => false, 
    4442        :auto_publish    => true, 
     
    231229  end 
    232230   
    233   # Return true if the site is configured to use a single language 
    234   def monolingual? 
    235     self[:monolingual] 
    236   end 
    237    
    238231  # Return true if the site is configured to allow private nodes 
    239232  def allow_private? 
  • trunk/app/views/sites/_li.erb

    r830 r1185  
    1010  <td class='site_group'  ><%= li.site_group.name   %></td> 
    1111  <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> 
    1313</tr> 
  • trunk/config/environment.rb

    r1121 r1185  
    1212require File.join(File.dirname(__FILE__), 'boot') 
    1313 
    14 # Set ZENA_ENV 
     14# Load zena specific settings 
    1515require File.join(File.dirname(__FILE__), 'zena') 
    1616require File.join(File.dirname(__FILE__), 'version') 
  • trunk/config/routes.rb

    r1094 r1185  
    6060  map.resources :data_entries, :member => { :zafu => :get } 
    6161 
    62   # FIXME monolingual 
    63    
    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   #else 
    86   #  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   #end 
    91   ##  
    92   ## # Allow downloading Web Service WSDL as a file with an extension 
    93   ## # 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    
    10062  # temporary routes... 
    10163  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' 
    10564   
    10665  # catch all 
    10766  map.connect '*path',  :controller => 'nodes',    :action => 'catch_all' 
    10867end 
    109 =begin 
    110 ActionController::Routing::Routes.draw do |map| 
    111   map.resources :relations 
    112  
    113   map.resources :links 
    114  
    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 :action 
    121  
    122   # You can have the root of your site routed by hooking up ''  
    123   # -- just remember to delete public/index.html. 
    124    
    125 end 
    126 =end 
  • trunk/config/zena.rb

    r1177 r1185  
    2222  puts "\n** WARNING: drb server not running. Upload progress will not work." 
    2323  puts " * WARNING: you should start the drb server with 'lib/upload_progress_server.rb start'\n\n" 
    24 end 
    25  
    26  
    27 # FIXME: Remove ZENA_ENV, not needed anymore 
    28 ZENA_ENV = { 
    29   :site_name => 'zena', 
    30   :root_id => 1, 
    31   :authorize => false, 
    32   :translate_group => 2, # default = admin 
    33   :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 default 
    40   :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 files 
    46   :edit_help_id => 3, 
    47 } 
    48 if ENV["RAILS_ENV"] != "test" 
    49   ZENA_ENV.freeze 
    5024end 
    5125 
  • trunk/db/schema.rb

    r1184 r1185  
    231231    t.column "name",               :string 
    232232    t.column "authentication",     :boolean 
    233     t.column "monolingual",        :boolean 
    234233    t.column "allow_private",      :boolean 
    235234    t.column "languages",          :string 
  • trunk/lib/node_query.rb

    r1173 r1185  
    202202      when 'l_'   
    203203        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) 
    205205          @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) 
    207207          # ok 
    208208          function ? "#{function}(#{table('links')}.#{key[2..-1]})" : "#{table('links')}.#{key[2..-1]}" 
  • trunk/lib/parser/lib/rules/zena.rb

    r1182 r1185  
    16151615    def r_icon 
    16161616      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')) 
    16181618        return unless finder 
    16191619        return parser_error("invalid class (#{klass})") unless klass.ancestors.include?(Node) 
  • trunk/test/functional/application_controller_test.rb

    r1050 r1185  
    134134  end 
    135135   
    136   def test_prefix 
    137     bak = ZENA_ENV[:monolingual] 
    138     ZENA_ENV[:monolingual] = false 
    139     @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] = true 
    146     @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] = bak 
    151   end 
    152    
    153136  def test_bad_session_user 
    154137    @controller.instance_variable_set(:@session, :user=>999, :host=>'test.host') 
  • trunk/test/helpers/zena_parser/relations.yml

    r1173 r1185  
    3737    node: 'cleanWater' 
    3838  src: "<r:icon do='[name]'/>" 
     39  tem: "/ORDER BY links.id DESC/" 
    3940  res: "lake" 
    4041   
  • trunk/test/sites/complex/sites.yml

    r1028 r1185  
    77  site_group:      complex 
    88  authentication:  yes 
    9   monolingual:     no 
    109  allow_private:   no 
    1110  auto_publish:    yes 
  • trunk/test/sites/ocean/sites.yml

    r1028 r1185  
    77  site_group:      aqua 
    88  authentication:  no 
    9   monolingual:     no 
    109  allow_private:   no 
    1110  auto_publish:    no 
  • trunk/test/sites/zena/sites.yml

    r1184 r1185  
    77  site_group:      workers 
    88  authentication:  no 
    9   monolingual:     no 
    109  allow_private:   yes 
    1110  auto_publish:    no 
  • trunk/test/unit/site_test.rb

    r1094 r1185  
    172172  end 
    173173   
    174   def test_monolingual 
    175     site = sites(:zena) 
    176     assert !site.monolingual?, "Multi lang site" 
    177     site.monolingual = true 
    178     assert site.save, "Can save" 
    179     assert site.monolingual?, "Mono lang site" 
    180   end 
    181    
    182174  def test_allow_private 
    183175    site = sites(:zena)