Changeset 548
- Timestamp:
- 2007-05-21 11:04:10 (2 years ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (5 diffs)
- trunk/app/controllers/nodes_controller.rb (modified) (2 diffs)
- trunk/db/init/base/skins/default/Project.html (modified) (1 diff)
- trunk/db/init/base/skins/default/layout.html (modified) (1 diff)
- trunk/db/schema.rb (modified) (2 diffs)
- trunk/lib/parser/lib/parser.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (2 diffs)
- trunk/lib/parser/test/parser_test.rb (modified) (2 diffs)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/lib/tasks/zena.rake (modified) (1 diff)
- trunk/test/integration/navigation_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r547 r548 283 283 # 1. site forces authentication 284 284 if (current_site.authentication? && visitor.is_anon?) 285 do_login 285 do_login and return false 286 286 end 287 287 … … 297 297 298 298 def do_login 299 session[:after_login_url] ||= request.parameters 299 300 if current_site[:http_auth] || true 300 301 basic_auth_required do |username, password| … … 303 304 end 304 305 end 305 # reset render306 return !visitor.is_anon?307 306 else 308 307 flash[:notice] = _("Please log in") 309 session[:after_login_url] = request.parameters 310 redirect_to login_path and return false 308 redirect_to login_path 311 309 end 312 310 end … … 318 316 # reset session lang, will be set from user on next request/filter 319 317 session[:lang] = nil 320 re turn true318 redirect_to session.delete(:after_login_url) || user_path(visitor) 321 319 end 322 320 … … 330 328 headers["Status"] = "Unauthorized" 331 329 headers["WWW-Authenticate"] = "Basic realm=\"#{realm}\"" 332 # FIXME: JS redirect instead of text if not site.authentication 330 331 # require login 333 332 if current_site.authentication? 334 333 render :nothing => true, :status => 401 trunk/app/controllers/nodes_controller.rb
r545 r548 318 318 def clean_url 319 319 if params[:prefix] == AUTHENTICATED_PREFIX && visitor.is_anon? 320 return false unless do_login320 do_login and return false 321 321 end 322 322 case params[:action] … … 334 334 335 335 if redirect_url 336 redirect_to redirect_url 337 return false 336 redirect_to redirect_url and return false 338 337 end 339 338 end trunk/db/init/base/skins/default/Project.html
r541 r548 13 13 14 14 <r:home> 15 <r:include template=' title.html'/>15 <r:include template='layout.html' part='body/container/main/title'/> 16 16 <r:summary text=''/> 17 17 <r:text/> 18 18 <r:else> 19 <r:include template=' title.html'/>19 <r:include template='layout.html' part='body/container/main/title'/> 20 20 </r:else> 21 21 </r:home> trunk/db/init/base/skins/default/layout.html
r541 r548 49 49 50 50 <div id='content' do='content_for_layout' name='content'> 51 <div id='main' do='void' name='main'></div> 51 <div id='main' do='void' name='main'> 52 <div class='header' name='title'> 53 <r:if kind_of='Document'><p class="document"><r:link format="data"><r:img mode='pv'/></r:link></p></r:if> 54 <h1 do='title' class='s30' status='true' actions='all'>this is the title</h1> 55 <div class='subtitle'> 56 <r:case> 57 <r:when test='[user_id] == [v_user_id]'> 58 <r:trans>posted by</r:trans> <b do='author' do='show' attr='fullname'>Super Man</b> 59 </r:when> 60 <r:else> 61 <r:trans>original by</r:trans> <b do='author' do='show' attr='fullname'>Platon</b> 62 <r:trans>modified by</r:trans> <b do='version' do='author' do='show' attr='fullname'>Socrate</b> 63 </r:else> 64 </r:case> 65 </div> 66 </div> 67 </div> 52 68 53 69 <div id='related' do='void' name='related'> trunk/db/schema.rb
r545 r548 151 151 t.column "admin_group_id", :integer 152 152 t.column "site_group_id", :integer 153 t.column "trans_group_id", :integer154 153 t.column "name", :string 155 154 t.column "authentication", :boolean … … 175 174 t.column "klass", :string 176 175 t.column "mode", :string 176 end 177 178 create_table "tmp", :id => false, :force => true do |t| 179 t.column "a", :string, :limit => 50 180 t.column "b", :string, :limit => 50 177 181 end 178 182 trunk/lib/parser/lib/parser.rb
r546 r548 226 226 @text, absolute_url = self.class.get_template_text(@params[:template], @options[:helper], @options[:current_folder]) 227 227 228 absolute_url += "::#{@params[:part].gsub('/','_')}" if @params[:part] 228 229 if absolute_url 229 230 if @options[:included_history].include?(absolute_url) … … 237 238 @text = before_parse(@text) 238 239 enter(:void) # scan fetched text 239 @included_blocks = @blocks 240 if @params[:part] 241 @included_blocks = [find_part(@params[:part])] 242 else 243 @included_blocks = @blocks 244 end 240 245 241 246 @blocks = [] 242 247 @text = text 243 248 enter(:void) # normal scan on content 249 end 250 251 def find_part(path) 252 res = self 253 path.split('/').reject {|e| e==''}.each do |name| 254 res.blocks.each do |b| 255 next if b.kind_of?(String) 256 if b.params[:name] == name 257 res = b 258 name = nil 259 break 260 end 261 end 262 return nil if name # block not found 263 end 264 res 244 265 end 245 266 trunk/lib/parser/lib/rules/zena.rb
r546 r548 811 811 def r_cache 812 812 kpath = @params[:kpath] || Page.kpath 813 context = @params[:context] || @context[:name] || @options[:included_history][0]813 context = @params[:context] || @context[:name] || (@options[:included_history][0] || '').split('::')[0] 814 814 out "<% #{cache} = Cache.with(visitor.id, visitor.group_ids, #{helper.send(:lang).inspect}, #{kpath.inspect}, #{context.inspect}) do capture do %>" 815 815 out expand_with … … 1063 1063 1064 1064 def unique_name 1065 "#{@options[:included_history][0] }/#{((@context[:name] || 'list').split('/')[-1]).gsub(/[^\w\/]/,'_')}"1065 "#{@options[:included_history][0].split('::')[0]}/#{((@context[:name] || 'list').split('/')[-1]).gsub(/[^\w\/]/,'_')}" 1066 1066 end 1067 1067 trunk/lib/parser/test/parser_test.rb
r541 r548 2 2 #require 'ruby-debug' 3 3 #Debugger.start 4 unless Module.const_defined?(:ActiveRecord) 5 # blank definition from active_support/core_ext/blank.rb 6 class String #:nodoc: 7 def blank? 8 empty? || strip.empty? 9 end 10 end 11 end 4 12 5 13 module Zafu … … 36 44 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 37 45 def test_single 38 do_test('zafu', 'include_ replace_same')46 do_test('zafu', 'include_self') 39 47 end 40 48 trunk/lib/parser/test/zafu.yml
r541 r548 93 93 src: "include_menu: <r:include template='/default/menu'/>" 94 94 res: "include_menu: the [test]menu[/test] is nice" 95 96 named_parts: 97 src: "named_parts: <r:test name='start'>start from here to <r:hello name='sub'>sub</r:hello></r:test> ok." 98 res: "named_parts: [test {= :name=>'start'} {> :name=>'start'}]start from here to [hello {= :name=>'sub'}]sub[/hello][/test] ok." 99 100 include_self: 101 src: "IS: I like <r:void name='sub'>sub <r:hello/></r:void> and <r:include template='/include/self' part='sub'/>" 102 res: "IS: I like sub hello world! and sub hello world!" 103 104 include_part: 105 src: "IP: <r:include template='/named/parts' part='start/sub'/> PI." 106 res: "IP: hello world! PI." 95 107 96 108 include_context: trunk/lib/tasks/zena.rake
r523 r548 144 144 end 145 145 146 desc "Enable fulltext search in production mode"147 task :init_fulltext => :environment do148 ActiveRecord::Base.connection.execute "ALTER TABLE versions ENGINE = MyISAM;"149 # add fulltext index150 ActiveRecord::Base.connection.add_index "versions", ["title", "text", "summary"], :index_type => "FULLTEXT"151 end152 153 146 desc "Migrate the database through scripts in db/migrate. Target specific brick and version with BRICK=x and VERSION=x" 154 147 task :migrate => :environment do trunk/test/integration/navigation_test.rb
r545 r548 13 13 Site.connection.execute "UPDATE sites SET authentication = 1 WHERE id = 1" # test.host 14 14 get 'http://test.host/' 15 assert_redirected_to 'http://test.host/login' 16 17 reset! 18 post 'http://test.host/session', :login=>'tiger', :password=>'tiger' 19 assert_redirected_to 'http://test.host/users/4' 20 21 # 2. navigating out of '/oo' but logged in and format is not data 22 get 'http://test.host/fr' 23 assert_redirected_to 'http://test.host/oo' 24 follow_redirect! 25 assert_response :success 26 get 'http://test.host/fr/textdocument53.css' # data 27 assert_response :success 28 end 29 30 def test_authorize_http_auth 31 Site.connection.execute "UPDATE sites SET http_auth = 1 WHERE id = 1" # test.host 32 get 'http://test.host/' 33 assert_redirected_to 'http://test.host/en' 34 follow_redirect! 35 assert_response :success 36 37 # 1. site forces authentication 38 Site.connection.execute "UPDATE sites SET authentication = 1 WHERE id = 1" # test.host 39 get 'http://test.host/' 40 assert_response 401 # http_auth 15 41 assert_redirected_to 'http://test.host/login' 16 42
