Changeset 1073
- Timestamp:
- 03/14/07 17:02:01 (3 years ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (1 diff)
- trunk/app/models/earth/server.rb (modified) (1 diff)
- trunk/app/models/user.rb (modified) (1 diff)
- trunk/config/earth-webapp.yml (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r858 r1073 1 1 # Filters added to this controller will be run for all controllers in the application. 2 2 # Likewise, all the methods added will be available for all controllers. 3 4 require 'erb' 5 3 6 class ApplicationController < ActionController::Base 4 7 5 @@webapp_config = open(File.dirname(__FILE__) + "/../../config/earth-webapp.yml") { |f| YAML.load(f.read) } 6 8 @@webapp_config = YAML.load(ERB.new(File.read(File.join(File.dirname(__FILE__), "../../config/earth-webapp.yml"))).result) 9 10 def self.webapp_config 11 @@webapp_config 12 end 7 13 end trunk/app/helpers/application_helper.rb
r1007 r1073 58 58 # Note: need to reverse ancestors with behavior compatible to nested_set 59 59 # (as opposed to better_nested_set) 60 for dir in directory.ancestors.reverse 60 path_components = directory.ancestors.reverse 61 62 # Add top-most directory, if present 63 if not path_components.empty? 64 s += link_to(path_components[0][:name], :overwrite_params => {:path => path_components[0].path, :page => nil}) + '/' 65 66 # Remove top-most directory from component list 67 path_components = path_components[1..-1] 68 end 69 70 # Remove top-most directories from component list until breadcrumb size is acceptable 71 # Make sure that at least the parent directory is still in breadcrumb 72 stripped = false 73 while path_components.size > 1 \ 74 and path_components.inject(s.size) { |sum, dir| sum += dir.name.size+1 } > ApplicationController::webapp_config["max_breadcrumb_length"].to_i 75 path_components = path_components[1..-1] 76 stripped = true 77 end 78 79 s += ".../" if stripped 80 81 path_components.each do |dir| 61 82 s += link_to(dir[:name], :overwrite_params => {:path => dir.path, :page => nil}) + '/' 62 83 end trunk/app/models/earth/server.rb
r1053 r1073 5 5 class Server < ActiveRecord::Base 6 6 has_many :directories, :dependent => :delete_cascade, :order => :lft 7 8 cattr_accessor :config 9 cattr_accessor :heartbeat_grace_period 10 self.config = YAML.load(::File.open(::File.dirname(__FILE__) + "/../../../config/earth-webapp.yml")) 11 self.heartbeat_grace_period = eval(self.config["heartbeat_grace_period"]) 7 8 @@config = nil 9 def self.config 10 @@config = ApplicationController::webapp_config unless @@config 11 @@config 12 end 13 14 def self.heartbeat_grace_period 15 self.config["heartbeat_grace_period"].to_i 16 end 12 17 13 18 def Server.this_server trunk/app/models/user.rb
r978 r1073 2 2 cattr_accessor :config 3 3 attr_reader :uid, :name 4 5 self.config = YAML.load(File.open(File.dirname(__FILE__) + "/../../config/earth-webapp.yml")) 4 5 @@config = nil 6 def self.config 7 @@config = ApplicationController::webapp_config unless @@config 8 @@config 9 end 6 10 7 @@uid_to_name = ExpiringHash.new( eval(config["ldap_cache_time"]))11 @@uid_to_name = ExpiringHash.new(config["ldap_cache_time"].to_i) 8 12 9 13 def User.reset_cache 10 @@uid_to_name = ExpiringHash.new( eval(config["ldap_cache_time"]))14 @@uid_to_name = ExpiringHash.new(config["ldap_cache_time"].to_i) 11 15 end 12 16 trunk/config/earth-webapp.yml
r920 r1073 1 1 # Any parameters here affect the Earth web application 2 # 3 # This file is parsed with ERB, so you can insert ruby code using <%= "..." %> constructs 2 4 3 5 # Configuration for doing user and group name lookup from uid and gid … … 10 12 id_field: "uidNumber" 11 13 name_field: "uid" 12 ldap_cache_time: 1.days14 ldap_cache_time: <%= 1.days %> 13 15 14 16 # … … 17 19 # be caused by database load etc. 18 20 # 19 heartbeat_grace_period: 10.seconds 21 heartbeat_grace_period: <%= 10.seconds %> 22 23 # ----- Misc ----- 24 25 # Maximum length of breadcrumb trail in characters. The breadcrumb 26 # trail will always contain (if applicable): a link to root, a link to 27 # the current server, a link to the top-level directory on the server, 28 # a link to the parent directory, and the name of the current 29 # directory. Additional directories between the top-level directory 30 # and the parent directory will only be shown if the total length of 31 # the breadcrumb trail, in characters, is less or equal than the 32 # number configured below. 33 # 34 # Note that ideally, this would take the width of individual 35 # characters and the width of the browser window into account; at this 36 # point however this level of precision is not provided by Earth. 37 # 38 max_breadcrumb_length: 20 20 39 21 40 # ----- Graph Configuration -----
