Changeset 991
- Timestamp:
- 11/13/07 14:11:32 (1 year ago)
- Files:
-
- trunk/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb (modified) (3 diffs)
- trunk/lib/merb/server.rb (modified) (5 diffs)
- trunk/lib/merb/template/erubis.rb (modified) (2 diffs)
- trunk/lib/merb/view_context.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb
r833 r991 105 105 font-weight:bold; 106 106 color:#00BF10; 107 } 108 table.trace tr td.code a { 109 width: 20px; 110 float: left; 107 111 } 108 112 table.trace tr td.code .more { … … 165 169 </td> 166 170 <td class="path"> 167 <%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %> in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>" 171 <%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %> 172 <% unless line.match(/\.erb:/) %> 173 in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>" 174 <% else %> 175 (<strong>ERB Template</strong>) 176 <% end %> 168 177 </td> 169 178 <td class="line"> 170 <a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a> 179 <a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a> 171 180 </td> 172 181 </tr> … … 175 184 </td> 176 185 <td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %> 177 <a href="txmt://open?url=file://<%=file%>&line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? lcode[0..90]+'<span class="more">......</span>' : lcode%><%='</em>' if llineno==lineno.to_i %>186 <a href="txmt://open?url=file://<%=file%>&line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %> 178 187 <% end %> 179 188 trunk/lib/merb/server.rb
r988 r991 275 275 end 276 276 277 def load_controller_template_path_cache 278 279 # This gets all templates set in the controllers template roots 277 def template_paths(type = "*") 278 # This gets all templates set in the controllers template roots 280 279 template_paths = Merb::AbstractController._abstract_subclasses.map do |klass| 281 280 Object.full_const_get(klass)._template_root 282 281 end.uniq.map do |path| 283 Dir["#{path}/**/ *"]282 Dir["#{path}/**/#{type}"] 284 283 end 285 284 286 285 # This gets the templates that might be created outside controllers 287 286 # template roots. eg app/views/shared/* 288 template_paths << Dir["#{MERB_ROOT}/app/views/**/*"] 289 290 template_paths = template_paths.flatten.compact.uniq 291 287 template_paths << Dir["#{MERB_ROOT}/app/views/**/*"] if type == "*" 288 289 template_paths.flatten.compact.uniq || [] 290 end 291 292 def load_controller_template_path_cache 292 293 Merb::AbstractController.reset_template_path_cache! 293 294 … … 298 299 299 300 def load_erubis_inline_helpers 300 partials = Merb::AbstractController._abstract_subclasses.map {|x| 301 Dir.glob("#{Object.full_const_get(x)._template_root}/**/_*.erb") }.flatten 301 partials = template_paths("_*.erb") 302 302 303 303 partials.each do |partial| … … 329 329 def reload 330 330 return if !@@merb_opts[:reloader] || !Object.const_defined?(:MERB_PATHS) 331 331 332 # First we collect all files in the project (this will also grab newly added files) 332 333 project_files = MERB_PATHS.map { |path| Dir[@@merb_opts[:merb_root] + path] }.flatten.uniq 333 project_mtime = max_mtime project_files # Latest changed time of all project files 334 erb_partials = template_paths("_*.erb").map { |path| Dir[path] }.flatten.uniq 335 project_mtime = max_mtime(project_files + erb_partials) # Latest changed time of all project files 334 336 335 337 return if @mtime.nil? || @mtime >= project_mtime # Only continue if a file has changed … … 358 360 loaded_classes = Merb::Controller._subclasses - old_subclasses 359 361 load_action_arguments(loaded_classes) 360 load_controller_template_path_cache361 load_erubis_inline_helpers362 362 rescue Exception => e 363 363 puts "Error reloading file #{file}: #{e}" … … 370 370 end 371 371 end 372 372 373 # Rebuild the glob cache and erubis inline helpers 374 load_controller_template_path_cache 375 load_erubis_inline_helpers 376 373 377 @mtime = project_mtime # As the last action, update the current @mtime 374 378 end trunk/lib/merb/template/erubis.rb
r988 r991 16 16 template_method = template.gsub(/[\/:]/, "__").gsub(/\./, "_") 17 17 18 unless self.respond_to?(template_method) 19 raise Merb::ControllerExceptions::TemplateNotFound, "No template matched at #{template}" 20 end 21 18 22 if with = opts.delete(:with) 19 23 as = opts.delete(:as) || template.match(/(.*\/_)([^\.]*)/)[2] … … 21 25 sent_template = [with].flatten.map do |temp| 22 26 @_merb_partial_locals[as.to_sym] = temp 23 send(template_method) rescue raise Merb::ControllerExceptions::TemplateNotFound, 24 "No template matched at #{template}" 27 send(template_method) 25 28 end.join 26 29 else 27 30 @_merb_partial_locals = opts 28 sent_template = send(template_method) rescue nil31 sent_template = send(template_method) 29 32 end 30 33 31 34 return sent_template if sent_template 32 35 33 raise Merb::ControllerExceptions::TemplateNotFound, "No template matched at #{template}"34 36 end 35 37 36 38 def method_missing(sym, *args, &blk) 37 @_merb_partial_locals[sym] || @web_controller.send(sym, *args, &blk) rescue super39 @_merb_partial_locals[sym] || @web_controller.send(sym, *args, &blk) 38 40 end 39 41 trunk/lib/merb/view_context.rb
r986 r991 69 69 # and delegate them back to the controller. 70 70 def method_missing(sym, *args, &blk) 71 @_merb_partial_locals[sym] || @web_controller.send(sym, *args, &blk) rescue super71 @_merb_partial_locals[sym] || @web_controller.send(sym, *args, &blk) 72 72 end 73 73
