diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-22 15:33:06 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2013-01-22 15:33:06 +0100 |
commit | 39aa7132ceed3d4beab3a9b828e571bbfc67c07e (patch) | |
tree | 6c88289c9f99be0af8635636fcdf64102090e5ec /lib | |
parent | 5ad8203ce4f1bfea997960d0b52c626dea24b944 (diff) | |
parent | 6f69c1a85055ec7c2515719d79d2a7a4e60cec50 (diff) |
Merge branch 'develop'5.1-beta1
Diffstat (limited to 'lib')
16 files changed, 83 insertions, 34 deletions
diff --git a/lib/activerecord_extensions.rb b/lib/activerecord_extensions.rb index 50c44be..102ddd8 100644 --- a/lib/activerecord_extensions.rb +++ b/lib/activerecord_extensions.rb @@ -16,7 +16,7 @@ class ActiveRecord::Base # def populate_gs_node_id if self.attribute_names.include?('gs_node_id') && self.gs_node_id.blank? - self.gs_node_id = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first.try(:id) + self.gs_node_id = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first.try(:id) end end @@ -47,7 +47,7 @@ class ActiveRecord::Base logger.error "Couldn't #{action} #{self.class} with the ID #{self.id} on other GsNodes because #{self.class} doesn't have a is_native attribute." else if self.is_native != false - if defined? WRITE_GS_CLUSTER_SYNC_LOG && WRITE_GS_CLUSTER_SYNC_LOG == true + if defined? GsParameter.get('WRITE_GS_CLUSTER_SYNC_LOG') && GsParameter.get('WRITE_GS_CLUSTER_SYNC_LOG') == true if !(defined? $gs_cluster_loop_protection) || $gs_cluster_loop_protection != true begin GsClusterSyncLogEntry.create( @@ -55,7 +55,7 @@ class ActiveRecord::Base :action => action, :content => content, :history => history, - :homebase_ip_address => HOMEBASE_IP_ADDRESS, + :homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'), :waiting_to_be_synced => true, :association_method => association_method, :association_uuid => association_uuid diff --git a/lib/bootstrap_breadcrumbs_builder.rb b/lib/bootstrap_breadcrumbs_builder.rb new file mode 100644 index 0000000..1d6326b --- /dev/null +++ b/lib/bootstrap_breadcrumbs_builder.rb @@ -0,0 +1,32 @@ +# The BootstrapBreadcrumbsBuilder is a Bootstrap compatible breadcrumb builder. +# It provides basic functionalities to render a breadcrumb navigation according to Bootstrap's conventions. +# +# BootstrapBreadcrumbsBuilder accepts a limited set of options: +# * separator: what should be displayed as a separator between elements +# +# You can use it with the :builder option on render_breadcrumbs: +# <%= render_breadcrumbs :builder => ::BootstrapBreadcrumbsBuilder, :separator => "»" %> +# +# Note: You may need to adjust the autoload_paths in your config/application.rb file for rails to load this class: +# config.autoload_paths += Dir["#{config.root}/lib/"] +# +class BootstrapBreadcrumbsBuilder < BreadcrumbsOnRails::Breadcrumbs::Builder + def render + @context.content_tag(:ul, class: 'breadcrumb') do + @elements.collect do |element| + render_element(element) + end.join.html_safe + end + end + + def render_element(element) + current = @context.current_page?(compute_path(element)) + + @context.content_tag(:li, :class => ('active' if current)) do + link_or_text = @context.link_to_unless_current(compute_name(element), compute_path(element), element.options) + divider = @context.content_tag(:span, (@options[:separator] || '/').html_safe, :class => 'divider') unless current + + link_or_text + (divider || '') + end + end +end
\ No newline at end of file diff --git a/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml b/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml index 4b43a3b..7f21ea3 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/edit.html.haml @@ -1,3 +1,3 @@ -- title "Sign up" +- content_for :title, "Sign up" = render "form" diff --git a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml index 22fc95b..3aebb44 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/login.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/login.html.haml @@ -1,4 +1,4 @@ -- title "Log in" +- content_for :title, "Log in" %p== Don't have an account? #{link_to "Sign up!", signup_path} diff --git a/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml b/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml index dc75c13..8557204 100644 --- a/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml +++ b/lib/generators/nifty/authentication/templates/views/haml/signup.html.haml @@ -1,4 +1,4 @@ -- title "Sign up" +- content_for :title, "Sign up" %p== Already have an account? #{link_to "Log in", login_path}. diff --git a/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml index 9cbea63..a523d32 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/_index_core.html.haml @@ -1,12 +1,12 @@ -%table +%table{:class => 'table table-striped'} %tr <%- for attribute in model_attributes -%> %th= t('<%= plural_name %>.index.<%= attribute.name %>') <%- end -%> - - reset_cycle + - for <%= instance_name %> in <%= instances_name %> - %tr{:class => cycle('odd', 'even')} + %tr <%- for attribute in model_attributes -%> %td= <%= instance_name %>.<%= attribute.name %> <%- end -%> diff --git a/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml index dc7de62..381fba0 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/edit.html.haml @@ -1,3 +1,3 @@ -- title t("<%= plural_name %>.edit.page_title") +- content_for :title, t("<%= plural_name %>.edit.page_title") <%= render_form %>
\ No newline at end of file diff --git a/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml index 86c6b9e..b6642ad 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/index.html.haml @@ -1,4 +1,4 @@ -- title t("<%= plural_name %>.index.page_title") +- content_for :title, t("<%= plural_name %>.index.page_title") - if @<%= instances_name %> && @<%= instances_name %>.count > 0 = render "index_core", :<%= instances_name %> => @<%= instances_name %> diff --git a/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml index 4e7f871..d9a6bb5 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/new.html.haml @@ -1,3 +1,3 @@ -- title t("<%= plural_name %>.new.page_title") +- content_for :title, t("<%= plural_name %>.new.page_title") <%= render_form %>
\ No newline at end of file diff --git a/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml b/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml index 3d01340..bd73c52 100644 --- a/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml +++ b/lib/generators/nifty/scaffold/templates/views/haml/show.html.haml @@ -1,4 +1,4 @@ -- title t("<%= plural_name %>.show.page_title") +- content_for :title, t("<%= plural_name %>.show.page_title") <%- for attribute in model_attributes -%> %p diff --git a/lib/tasks/cvs_user_import.rake b/lib/tasks/cvs_user_import.rake index 2475a43..81959d5 100644 --- a/lib/tasks/cvs_user_import.rake +++ b/lib/tasks/cvs_user_import.rake @@ -24,14 +24,14 @@ namespace :user_import do # Read the CSV data and store them in the new_users hash. # - csv_data = CSV.read(IMPORT_CSV_FILE, encoding: IMPORT_CSV_ENCODING) + csv_data = CSV.read(GsParameter.get('IMPORT_CSV_FILE'), encoding: GsParameter.get('IMPORT_CSV_ENCODING')) headers = csv_data.shift.map {|i| i.to_s } string_data = csv_data.map {|row| row.map {|cell| cell.to_s } } new_users = string_data.map {|row| Hash[*headers.zip(row).flatten] } - gs_node_id = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first.try(:id) + gs_node_id = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first.try(:id) - if File.exists?(DOUBLE_CHECK_POSITIVE_USERS_CSV) - csv_data = CSV.read(DOUBLE_CHECK_POSITIVE_USERS_CSV, encoding: IMPORT_CSV_ENCODING) + if File.exists?(GsParameter.get('DOUBLE_CHECK_POSITIVE_USERS_CSV')) + csv_data = CSV.read(GsParameter.get('DOUBLE_CHECK_POSITIVE_USERS_CSV'), encoding: GsParameter.get('IMPORT_CSV_ENCODING')) if csv_data.blank? double_checked_user_names = [] else @@ -45,13 +45,13 @@ namespace :user_import do double_checked_user_names = new_users.map{|user| user['UserName']} end - tenant = Tenant.find(DEFAULT_API_TENANT_ID) + tenant = Tenant.find(GsParameter.get('DEFAULT_API_TENANT_ID')) # Destroy deleted user by making a diff of where(:importer_checksum) # and users in the CSV file. # - if defined?(USER_NAME_PREFIX) && !USER_NAME_PREFIX.blank? - new_users_user_names = new_users.map{|x| USER_NAME_PREFIX.to_s + x['UserName'].to_s} + if defined?(GsParameter.get('USER_NAME_PREFIX')) && !GsParameter.get('USER_NAME_PREFIX').blank? + new_users_user_names = new_users.map{|x| GsParameter.get('USER_NAME_PREFIX').to_s + x['UserName'].to_s} else new_users_user_names = new_users.map{|x| x['UserName']} end @@ -67,8 +67,8 @@ namespace :user_import do new_users.each do |csv_user| if !(csv_user['UserName'].blank? || csv_user['Email'].blank?) && double_checked_user_names.include?(csv_user['UserName']) csv_user['Email'] = csv_user['Email'].downcase - if defined?(USER_NAME_PREFIX) && !USER_NAME_PREFIX.blank? - csv_user['UserName'] = USER_NAME_PREFIX.to_s + csv_user['UserName'] + if defined?(GsParameter.get('USER_NAME_PREFIX')) && !GsParameter.get('USER_NAME_PREFIX').blank? + csv_user['UserName'] = GsParameter.get('USER_NAME_PREFIX').to_s + csv_user['UserName'] end md5_sum = Digest::MD5.hexdigest(csv_user.to_yaml) @@ -177,7 +177,7 @@ namespace :user_import do if phone_numbers_count < sip_account.phone_numbers.count call_forward_case_offline = CallForwardCase.find_by_value('offline') if call_forward_case_offline - sip_account.phone_numbers.first.call_forwards.create(:call_forward_case_id => call_forward_case_offline.id, :call_forwardable_type => 'Voicemail', :active => true, :depth => DEFAULT_CALL_FORWARD_DEPTH) + sip_account.phone_numbers.first.call_forwards.create(:call_forward_case_id => call_forward_case_offline.id, :call_forwardable_type => 'Voicemail', :active => true, :depth => GsParameter.get('DEFAULT_CALL_FORWARD_DEPTH')) end end else @@ -280,8 +280,8 @@ namespace :user_import do conference.start = nil conference.end = nil conference.open_for_anybody = true - conference.max_members = DEFAULT_MAX_CONFERENCE_MEMBERS - conference.pin = (1..MINIMUM_PIN_LENGTH).map{|i| (0 .. 9).to_a.sample}.join + conference.max_members = GsParameter.get('DEFAULT_MAX_CONFERENCE_MEMBERS') + conference.pin = (1..GsParameter.get('MINIMUM_PIN_LENGTH')).map{|i| (0 .. 9).to_a.sample}.join conference.save end @@ -314,7 +314,7 @@ namespace :user_import do cell_phone_number = csv_user['CellPhone'].to_s.gsub(/[^0-9\+]/, '') if !cell_phone_number.blank? - callthrough = tenant.callthroughs.find_or_create_by_name(CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION) + callthrough = tenant.callthroughs.find_or_create_by_name(GsParameter.get('CALLTHROUGH_NAME_TO_BE_USED_FOR_DEFAULT_ACTIVATION')) access_authorization = callthrough.access_authorizations.find_or_create_by_name('Cellphones') diff --git a/lib/tasks/fax.rake b/lib/tasks/fax.rake index 1f1c282..41ae7cf 100644 --- a/lib/tasks/fax.rake +++ b/lib/tasks/fax.rake @@ -37,7 +37,7 @@ task :import_inbound_fax, [ -o \"#{pdf_file}\" \\ -p #{paper_size} \\ -a \"#{fax_arguments[:remote_station_id]}\" \\ - -c \"AMOOMA Gemeinschaft version #{GEMEINSCHAFT_VERSION}\" \\ + -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\ -t \"#{fax_arguments[:remote_station_id]}\" \"#{tiff_file}\"" if !File.exists?( pdf_file ) diff --git a/lib/tasks/gs_cluster.rake b/lib/tasks/gs_cluster.rake index 565fd83..7b49ebb 100644 --- a/lib/tasks/gs_cluster.rake +++ b/lib/tasks/gs_cluster.rake @@ -1,15 +1,15 @@ namespace :gs_cluster do desc "Sync local data to other gs cluster nodes." task :push_waiting_data_to_other_nodes => :environment do - infinity_loop_protection_counter = GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS, + infinity_loop_protection_counter = GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'), :waiting_to_be_synced => true).count + 10 # One bite at a time. # - while GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS, + while GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'), :waiting_to_be_synced => true).any? && infinity_loop_protection_counter > 0 - GsClusterSyncLogEntry.where(:homebase_ip_address => HOMEBASE_IP_ADDRESS, + GsClusterSyncLogEntry.where(:homebase_ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS'), :waiting_to_be_synced => true).first.populate_other_cluster_nodes infinity_loop_protection_counter -= 1 end @@ -38,7 +38,7 @@ namespace :gs_cluster do desc "Pull objects from nodes." task :pull => :environment do - local_node = GsNode.where(:ip_address => HOMEBASE_IP_ADDRESS).first + local_node = GsNode.where(:ip_address => GsParameter.get('HOMEBASE_IP_ADDRESS')).first GsNode.where(:accepts_updates_from => true).each do |remote_node| if remote_node.id == local_node.id next diff --git a/lib/tasks/heater.rake b/lib/tasks/heater.rake new file mode 100644 index 0000000..11862a5 --- /dev/null +++ b/lib/tasks/heater.rake @@ -0,0 +1,17 @@ +namespace :heater do + desc "Warm up the cache." + task :preheat => :environment do + if GemeinschaftSetup.any? + + else + # This is a fresh installation. + # + if Rails.env.production? + require 'open-uri' + open('/dev/null', 'wb') do |file| + file << open("http://localhost/gemeinschaft_setups/new").read + end + end + end + end +end
\ No newline at end of file diff --git a/lib/tasks/send_fax_notifications.rake b/lib/tasks/send_fax_notifications.rake index 039c509..2ac74c8 100644 --- a/lib/tasks/send_fax_notifications.rake +++ b/lib/tasks/send_fax_notifications.rake @@ -23,7 +23,7 @@ task :send_fax_notifications => :environment do -o \"#{pdf_file}\" \\ -p #{paper_size} \\ -a \"#{fax_document.remote_station_id}\" \\ - -c \"AMOOMA Gemeinschaft version #{GEMEINSCHAFT_VERSION}\" \\ + -c \"AMOOMA Gemeinschaft version #{GsParameter.get('GEMEINSCHAFT_VERSION')}\" \\ -t \"#{fax_document.remote_station_id}\" \"#{TMP_DIR}#{tiff_file}\"" if !File.exists?( pdf_file ) diff --git a/lib/templates/erb/scaffold/_form.html.erb b/lib/templates/erb/scaffold/_form.html.erb index 24a1768..201a069 100644 --- a/lib/templates/erb/scaffold/_form.html.erb +++ b/lib/templates/erb/scaffold/_form.html.erb @@ -1,13 +1,13 @@ <%%= simple_form_for(@<%= singular_table_name %>) do |f| %> <%%= f.error_notification %> - <div class="inputs"> + <div class="form-inputs"> <%- attributes.each do |attribute| -%> <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %> <%- end -%> </div> - <div class="actions"> + <div class="form-actions"> <%%= f.button :submit %> </div> <%% end %> |