kit_cms 2.3.20 → 2.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/images/kit/toolbar/smile.png +0 -0
 - data/app/assets/images/kit/toolbar/wink.gif +0 -0
 - data/app/assets/images/kit/toolbar/wink.png +0 -0
 - data/app/assets/javascripts/codemirror/editor.js +55 -17
 - data/app/assets/javascripts/codemirror/jquery.js +0 -1
 - data/app/assets/javascripts/codemirror/ruby.js +196 -0
 - data/app/assets/javascripts/jquery.js +3036 -2838
 - data/app/assets/javascripts/kit/utilities.js +655 -586
 - data/app/assets/stylesheets/codemirror/style.css +1 -1
 - data/app/assets/stylesheets/codemirror/theme.css +23 -3
 - data/app/assets/stylesheets/kit/calendar.css +6 -1
 - data/app/assets/stylesheets/kit/cms/cms.css +36 -0
 - data/app/assets/stylesheets/kit/forums.css +5 -1
 - data/app/assets/stylesheets/kit/kit.css +3 -1
 - data/app/controllers/account_controller.rb +306 -0
 - data/app/controllers/ad_controller.rb +2 -0
 - data/app/controllers/admin/ad_units_controller.rb +1 -1
 - data/app/controllers/admin/ad_zones_controller.rb +15 -0
 - data/app/controllers/admin/ads_controller.rb +5 -0
 - data/app/controllers/admin/block_controller.rb +1 -65
 - data/app/controllers/admin/blocks_controller.rb +2 -0
 - data/app/controllers/admin/content_controller.rb +3 -1
 - data/app/controllers/admin/dashboard_controller.rb +28 -4
 - data/app/controllers/admin/dj_controller.rb +45 -0
 - data/app/controllers/admin/help_controller.rb +1 -1
 - data/app/controllers/admin/html_asset_controller.rb +0 -12
 - data/app/controllers/admin/q_controller.rb +120 -0
 - data/app/controllers/admin/user_controller.rb +4 -4
 - data/app/controllers/api_controller.rb +34 -0
 - data/app/controllers/calendar_controller.rb +1 -1
 - data/app/controllers/form_controller.rb +3 -3
 - data/app/controllers/forum_controller.rb +39 -29
 - data/app/controllers/kit_controller.rb +42 -15
 - data/app/controllers/pages_controller.rb +25 -5
 - data/app/controllers/q_controller.rb +235 -0
 - data/app/controllers/repo_controller.rb +7 -0
 - data/app/controllers/user_controller.rb +14 -10
 - data/app/controllers/utility_controller.rb +1 -1
 - data/app/helpers/account_helper.rb +47 -0
 - data/app/helpers/admin/layouts_helper.rb +8 -0
 - data/app/helpers/admin/page_templates_helper.rb +8 -0
 - data/app/helpers/ads_helper.rb +11 -12
 - data/app/helpers/calendar_helper.rb +6 -2
 - data/app/helpers/form_data_helper.rb +1 -1
 - data/app/helpers/form_helper.rb +8 -0
 - data/app/helpers/forum_helper.rb +5 -1
 - data/app/helpers/kit_helper.rb +65 -35
 - data/app/helpers/kit_modules_helper.rb +4 -0
 - data/app/helpers/user_helper.rb +0 -28
 - data/app/jobs/page_link_job.rb +34 -0
 - data/app/jobs/queue_job.rb +134 -0
 - data/app/mailers/notification.rb +10 -0
 - data/app/mailers/queue_mailer.rb +13 -0
 - data/app/models/ad.rb +6 -6
 - data/app/models/ad_unit.rb +1 -1
 - data/app/models/ad_zone.rb +4 -0
 - data/app/models/block.rb +1 -1
 - data/app/models/delayed_job.rb +3 -0
 - data/app/models/form.rb +16 -4
 - data/app/models/html_asset.rb +19 -4
 - data/app/models/html_asset_usage.rb +3 -0
 - data/app/models/html_assetable.rb +4 -0
 - data/app/models/layout.rb +36 -6
 - data/app/models/newsletter.rb +1 -1
 - data/app/models/page.rb +36 -2
 - data/app/models/page_link.rb +5 -0
 - data/app/models/page_template.rb +22 -2
 - data/app/models/preference.rb +1 -1
 - data/app/models/q_event.rb +12 -0
 - data/app/models/q_klass.rb +5 -0
 - data/app/models/q_message.rb +9 -0
 - data/app/models/q_publisher.rb +35 -0
 - data/app/models/q_subscription.rb +7 -0
 - data/app/models/q_user.rb +29 -0
 - data/app/models/q_users_method.rb +6 -0
 - data/app/models/q_users_publisher.rb +6 -0
 - data/app/models/user.rb +127 -19
 - data/app/models/user_login.rb +4 -0
 - data/app/validators/email_validator.rb +14 -0
 - data/app/views/account/_edit.html.haml +40 -0
 - data/app/views/account/_edit_intro.html.haml +3 -0
 - data/app/views/account/_forgotten.html.haml +20 -0
 - data/app/views/account/_forgotten_intro.html.haml +5 -0
 - data/app/views/account/_sign_in.html.haml +31 -0
 - data/app/views/account/_sign_in_intro.html.haml +4 -0
 - data/app/views/account/_sign_up.html.haml +51 -0
 - data/app/views/account/_sign_up_intro.html.haml +4 -0
 - data/app/views/account/edit.html.haml +1 -0
 - data/app/views/account/forgotten.html.haml +1 -0
 - data/app/views/account/sign_in.html.haml +2 -0
 - data/app/views/account/sign_up.html.haml +1 -0
 - data/app/views/ad/_buy.html.haml +2 -1
 - data/app/views/admin/ad_zones/_form.html.haml +1 -1
 - data/app/views/admin/ad_zones/show.html.haml +2 -0
 - data/app/views/admin/blocks/_form.html.haml +11 -1
 - data/app/views/admin/dashboard/broken_links.html.haml +9 -0
 - data/app/views/admin/dashboard/system.html.haml +11 -0
 - data/app/views/admin/dj/index.html.haml +43 -0
 - data/app/views/admin/form/_form.html.haml +15 -10
 - data/app/views/admin/group/index.html.haml +1 -1
 - data/app/views/admin/help/edit.html.haml +1 -1
 - data/app/views/admin/html_asset/show.html.haml +9 -2
 - data/app/views/admin/layouts/show.html.haml +10 -16
 - data/app/views/admin/page_templates/_form.html.haml +9 -17
 - data/app/views/admin/page_templates/show.html.haml +5 -4
 - data/app/views/admin/q/events.html.haml +26 -0
 - data/app/views/admin/q/index.html.haml +28 -0
 - data/app/views/admin/q/klasses.html.haml +61 -0
 - data/app/views/admin/q/messages.html.haml +37 -0
 - data/app/views/admin/q/show.html.haml +98 -0
 - data/app/views/admin/q/subscriptions.html.haml +26 -0
 - data/app/views/admin/q/users.html.haml +27 -0
 - data/app/views/admin/snippet/edit.html.erb +1 -1
 - data/app/views/admin/snippet/new.html.erb +1 -1
 - data/app/views/admin/stylesheet/show.html.haml +1 -1
 - data/app/views/admin/user/index.html.erb +15 -6
 - data/app/views/admin/user/view.html.erb +5 -4
 - data/app/views/admin/views/_form.html.haml +3 -3
 - data/app/views/calendar/_buy_tickets.html.haml +1 -1
 - data/app/views/calendar/_calendar_entry.html.haml +1 -1
 - data/app/views/calendar/_month.html.haml +7 -7
 - data/app/views/form/_show.html.haml +1 -1
 - data/app/views/forum/_add_post.html.haml +7 -8
 - data/app/views/forum/_mod_thread.js.erb +46 -6
 - data/app/views/forum/_post_moderation.html.haml +2 -1
 - data/app/views/forum/_post_preview.html.haml +1 -9
 - data/app/views/forum/_post_scripts.js.erb +29 -5
 - data/app/views/forum/fetch_raw.html.haml +1 -0
 - data/app/views/forum/moderate.html.haml +1 -0
 - data/app/views/forum/topic_index.html.haml +4 -0
 - data/app/views/notification/{event.txt.erb → event.text.erb} +0 -0
 - data/app/views/notification/forgotten_password.text.erb +2 -0
 - data/app/views/pages/content_edit.html.haml +1 -1
 - data/app/views/pages/info.html.erb +13 -2
 - data/app/views/pages/links.html.haml +63 -0
 - data/app/views/user/edit_profile.html.haml +1 -1
 - data/app/views/utility/_cm_editor.html.erb +13 -10
 - data/app/views/utility/_cm_toolbar_markdown.html.haml +8 -1
 - data/app/views/utility/_menu.html.haml +4 -0
 - data/app/views/utility/mercury_html.html.haml +1 -0
 - data/config/initializers/elastic_search.rb +6 -3
 - data/config/initializers/extend_controller.rb +3 -0
 - data/config/initializers/string.rb +9 -6
 - data/config/initializers/warden.rb +49 -0
 - data/config/locales/en.yml +29 -1
 - data/config/routes.rb +35 -2
 - data/lib/kit_cms.rb +7 -2
 - data/lib/tasks/kit.rake +90 -2
 - metadata +139 -27
 - data/app/controllers/user/confirmations_controller.rb +0 -11
 - data/app/controllers/user/passwords_controller.rb +0 -13
 - data/app/controllers/user/registrations_controller.rb +0 -110
 - data/app/controllers/user/sessions_controller.rb +0 -33
 - data/app/controllers/user/unlocks_controller.rb +0 -13
 - data/app/views/devise/_links.erb +0 -25
 - data/app/views/devise/confirmations/new.html.erb +0 -12
 - data/app/views/devise/mailer/confirmation_instructions.html.erb +0 -5
 - data/app/views/devise/mailer/reset_password_instructions.html.erb +0 -8
 - data/app/views/devise/mailer/unlock_instructions.html.erb +0 -7
 - data/app/views/devise/passwords/edit.html.erb +0 -16
 - data/app/views/devise/passwords/new.html.erb +0 -12
 - data/app/views/devise/registrations/edit.html.erb +0 -28
 - data/app/views/devise/registrations/new.html.erb +0 -18
 - data/app/views/devise/sessions/new.html.erb +0 -18
 - data/app/views/devise/shared/_links.erb +0 -25
 - data/app/views/devise/unlocks/new.html.erb +0 -12
 - data/app/views/pages/links.html.erb +0 -8
 - data/app/views/user/shared/_links.erb +0 -25
 - data/config/initializers/devise.rb +0 -196
 - data/config/initializers/devise_extender.rb +0 -39
 
    
        data/app/models/ad.rb
    CHANGED
    
    | 
         @@ -1,8 +1,10 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Ad < ActiveRecord::Base
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
              include ActionView::Helpers
         
     | 
| 
       3 
3 
     | 
    
         
             
              attr_accessor :duration
         
     | 
| 
       4 
4 
     | 
    
         
             
              attr_accessor :not_found
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
      
 6 
     | 
    
         
            +
              attr_accessible :impression_count, :start_date, :end_date, :user_id, :name, :is_house_ad, :weighting, :body, :allow_html, :creative, :link, :price_paid, :paid_at, :notes, :creative, :create_file_name
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
       6 
8 
     | 
    
         
             
              has_many :order_items, :as=>:orderable
         
     | 
| 
       7 
9 
     | 
    
         
             
              belongs_to :sellable, :polymorphic=>true 
         
     | 
| 
       8 
10 
     | 
    
         | 
| 
         @@ -13,7 +15,6 @@ class Ad < ActiveRecord::Base 
     | 
|
| 
       13 
15 
     | 
    
         
             
              has_many :ad_clicks
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
17 
     | 
    
         
             
              validates :system_id, :presence=>true
         
     | 
| 
       16 
     | 
    
         
            -
              validates :user_id, :presence=>true
         
     | 
| 
       17 
18 
     | 
    
         
             
              validates :start_date, :presence=>true
         
     | 
| 
       18 
19 
     | 
    
         
             
              validates :end_date, :presence=>true
         
     | 
| 
       19 
20 
     | 
    
         
             
              validates :name, :presence=>true
         
     | 
| 
         @@ -96,9 +97,9 @@ class Ad < ActiveRecord::Base 
     | 
|
| 
       96 
97 
     | 
    
         
             
                ad = self
         
     | 
| 
       97 
98 
     | 
    
         | 
| 
       98 
99 
     | 
    
         
             
                if ad.creative_file_name
         
     | 
| 
       99 
     | 
    
         
            -
                  content =  
     | 
| 
      
 100 
     | 
    
         
            +
                  content = "<img src='#{ad.creative.url(options[:preview] ? :thumb : :display)}' />".html_safe
         
     | 
| 
       100 
101 
     | 
    
         
             
                else
         
     | 
| 
       101 
     | 
    
         
            -
                  content = ad.not_found ? "[[ad not found]]" : (ad.allow_html==1 ? ad.body : (h ad.body))
         
     | 
| 
      
 102 
     | 
    
         
            +
                  content = ad.not_found ? "[[ad not found]]" : (ad.body.is_blank ? "[[no HTML]]" : (ad.allow_html==1 ? ad.body : (h ad.body)))
         
     | 
| 
       102 
103 
     | 
    
         
             
                end
         
     | 
| 
       103 
104 
     | 
    
         | 
| 
       104 
105 
     | 
    
         
             
                op = []
         
     | 
| 
         @@ -134,9 +135,8 @@ class Ad < ActiveRecord::Base 
     | 
|
| 
       134 
135 
     | 
    
         
             
                    adsa << ad
         
     | 
| 
       135 
136 
     | 
    
         
             
                  end
         
     | 
| 
       136 
137 
     | 
    
         
             
                end 
         
     | 
| 
       137 
     | 
    
         
            -
                 
     | 
| 
      
 138 
     | 
    
         
            +
                adsa[rand(adsa.length-1)]
         
     | 
| 
       138 
139 
     | 
    
         | 
| 
       139 
     | 
    
         
            -
                adsa[rand_id]
         
     | 
| 
       140 
140 
     | 
    
         
             
              end    
         
     | 
| 
       141 
141 
     | 
    
         | 
| 
       142 
142 
     | 
    
         
             
              def impress
         
     | 
    
        data/app/models/ad_unit.rb
    CHANGED
    
    
    
        data/app/models/ad_zone.rb
    CHANGED
    
    | 
         @@ -7,6 +7,10 @@ class AdZone < ActiveRecord::Base 
     | 
|
| 
       7 
7 
     | 
    
         
             
              has_many :ad_zones_ads
         
     | 
| 
       8 
8 
     | 
    
         
             
              has_many :ads, :through=>:ad_zones_ads
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
      
 10 
     | 
    
         
            +
             def block_name
         
     | 
| 
      
 11 
     | 
    
         
            +
               "Ad from zone '#{self.name}'"
         
     | 
| 
      
 12 
     | 
    
         
            +
             end
         
     | 
| 
      
 13 
     | 
    
         
            +
                
         
     | 
| 
       10 
14 
     | 
    
         
             
              def display_name_with_price
         
     | 
| 
       11 
15 
     | 
    
         
             
                "#{self.name} (#{self.width}x#{self.height}) @ £#{('%.2f' % self.price_per_period)}/#{self.period.singularize}".html_safe
         
     | 
| 
       12 
16 
     | 
    
         
             
              end
         
     | 
    
        data/app/models/block.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Block < ActiveRecord::Base
         
     | 
| 
       2 
2 
     | 
    
         
             
              has_and_belongs_to_many :page_templates
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
              attr_accessible :name, :show_editors, :all_templates, :page_template_ids, :description, :body, :system_id
         
     | 
| 
      
 4 
     | 
    
         
            +
              attr_accessible :name, :show_editors, :all_templates, :page_template_ids, :description, :body, :system_id, :user_id
         
     | 
| 
       5 
5 
     | 
    
         
             
              validates :name, :presence=>true, :length=>{:minimum=>1, :maximum=>80}
         
     | 
| 
       6 
6 
     | 
    
         
             
              belongs_to :user
         
     | 
| 
       7 
7 
     | 
    
         | 
    
        data/app/models/form.rb
    CHANGED
    
    | 
         @@ -3,10 +3,14 @@ require 'net/http' 
     | 
|
| 
       3 
3 
     | 
    
         
             
            require 'digest/md5'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            class Form < ActiveRecord::Base
         
     | 
| 
      
 6 
     | 
    
         
            +
              has_many :html_assetable, :as=>:html_assetable
         
     | 
| 
      
 7 
     | 
    
         
            +
              has_many :html_assets, :through=>:html_assetable
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       6 
9 
     | 
    
         
             
              has_many :form_fields, :dependent => :destroy, :order=>:display_order
         
     | 
| 
       7 
10 
     | 
    
         
             
              has_many :form_field_groups, :order=>:order_by
         
     | 
| 
       8 
11 
     | 
    
         
             
              has_many :form_submissions, :dependent => :destroy
         
     | 
| 
       9 
12 
     | 
    
         | 
| 
      
 13 
     | 
    
         
            +
              belongs_to :layout
         
     | 
| 
       10 
14 
     | 
    
         
             
              has_many :ungrouped_form_fields, :class_name=>"FormField", :conditions=>"form_fields.form_field_group_id is null"  
         
     | 
| 
       11 
15 
     | 
    
         
             
              validates :title, :uniqueness=>{:scope=>:system_id}, :presence=>true
         
     | 
| 
       12 
16 
     | 
    
         
             
              validates :url, :uniqueness=>true, :allow_blank=>true
         
     | 
| 
         @@ -16,9 +20,16 @@ class Form < ActiveRecord::Base 
     | 
|
| 
       16 
20 
     | 
    
         
             
                self.form_fields.joins(:form_field_type).where("form_field_types.field_type in ('line','paragraph','select','multiselect')").all
         
     | 
| 
       17 
21 
     | 
    
         
             
              end
         
     | 
| 
       18 
22 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
              def  
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
              def javascripts
         
     | 
| 
      
 24 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"js").all
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def stylesheets
         
     | 
| 
      
 28 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"css").all
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
         
     | 
| 
      
 31 
     | 
    
         
            +
              def old_stylesheets
         
     | 
| 
      
 32 
     | 
    
         
            +
                self.read_attribute(:stylesheets)
         
     | 
| 
       22 
33 
     | 
    
         
             
              end
         
     | 
| 
       23 
34 
     | 
    
         | 
| 
       24 
35 
     | 
    
         
             
              def field_by_name(name)
         
     | 
| 
         @@ -156,7 +167,8 @@ class Form < ActiveRecord::Base 
     | 
|
| 
       156 
167 
     | 
    
         
             
              end
         
     | 
| 
       157 
168 
     | 
    
         | 
| 
       158 
169 
     | 
    
         
             
              def self.get_textcaptcha_qa
         
     | 
| 
       159 
     | 
    
         
            -
                xml   = Net::HTTP.get(URI::Parser.new.parse("http://textcaptcha.com/api/7zsxcgrbaacc4cs4swsswk4sk863uwld"))
         
     | 
| 
      
 170 
     | 
    
         
            +
                xml   = Net::HTTP.get(URI::Parser.new.parse("http://textcaptcha.com/api/7zsxcgrbaacc4cs4swsswk4sk863uwld")) rescue nil
         
     | 
| 
      
 171 
     | 
    
         
            +
                return unless xml
         
     | 
| 
       160 
172 
     | 
    
         
             
                if xml.empty?
         
     | 
| 
       161 
173 
     | 
    
         
             
                  raise Textcaptcha::BadResponse
         
     | 
| 
       162 
174 
     | 
    
         
             
                else
         
     | 
    
        data/app/models/html_asset.rb
    CHANGED
    
    | 
         @@ -1,4 +1,18 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class HtmlAsset < ActiveRecord::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
            #  has_many :page_template_html_assets
         
     | 
| 
      
 3 
     | 
    
         
            +
            #  has_many :layout_html_assets
         
     | 
| 
      
 4 
     | 
    
         
            +
            #  has_many :page_templates, :through=>:page_template_html_assets
         
     | 
| 
      
 5 
     | 
    
         
            +
            #  has_many :layouts, :through=>:layout_html_assets
         
     | 
| 
      
 6 
     | 
    
         
            +
            #  has_many :form_html_assets
         
     | 
| 
      
 7 
     | 
    
         
            +
            #  has_many :forms, :through=>:form_html_assets
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              has_many :html_assetables
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
              has_many :layouts, :through=>:html_assetables, :source=>:html_assetable, :source_type=>"Layout"
         
     | 
| 
      
 12 
     | 
    
         
            +
              has_many :page_templates, :through=>:html_assetables, :source=>:html_assetable, :source_type=>"PageTemplate"
         
     | 
| 
      
 13 
     | 
    
         
            +
              has_many :forms, :through=>:html_assetables, :source=>:html_assetable, :source_type=>"Form"
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
       2 
16 
     | 
    
         
             
              belongs_to :user
         
     | 
| 
       3 
17 
     | 
    
         
             
              validates :name, :presence=>true, :length=>{:minimum=>1, :maximum=>80}
         
     | 
| 
       4 
18 
     | 
    
         
             
              before_save :generate_fingerprint
         
     | 
| 
         @@ -7,6 +21,7 @@ class HtmlAsset < ActiveRecord::Base 
     | 
|
| 
       7 
21 
     | 
    
         
             
              attr_accessor :compiled
         
     | 
| 
       8 
22 
     | 
    
         | 
| 
       9 
23 
     | 
    
         
             
              before_save :record_history
         
     | 
| 
      
 24 
     | 
    
         
            +
              after_save :write_to_file
         
     | 
| 
       10 
25 
     | 
    
         | 
| 
       11 
26 
     | 
    
         
             
              def display_name
         
     | 
| 
       12 
27 
     | 
    
         
             
                full_type
         
     | 
| 
         @@ -23,7 +38,7 @@ class HtmlAsset < ActiveRecord::Base 
     | 
|
| 
       23 
38 
     | 
    
         
             
              end
         
     | 
| 
       24 
39 
     | 
    
         | 
| 
       25 
40 
     | 
    
         
             
              def self.fetch(system_id, name, type)
         
     | 
| 
       26 
     | 
    
         
            -
                Rails.cache.fetch(HtmlAsset.cache_key(system_id, name.downcase, type), :expires_in=> 
     | 
| 
      
 41 
     | 
    
         
            +
                Rails.cache.fetch(HtmlAsset.cache_key(system_id, name.downcase, type), :expires_in=>1.second) do 
         
     | 
| 
       27 
42 
     | 
    
         
             
                  asset = HtmlAsset.sys(system_id).where(:name=>name.downcase).where(:file_type=>type).first
         
     | 
| 
       28 
43 
     | 
    
         
             
                  asset.write_to_file if asset
         
     | 
| 
       29 
44 
     | 
    
         
             
                  asset
         
     | 
| 
         @@ -35,11 +50,11 @@ class HtmlAsset < ActiveRecord::Base 
     | 
|
| 
       35 
50 
     | 
    
         
             
              end
         
     | 
| 
       36 
51 
     | 
    
         | 
| 
       37 
52 
     | 
    
         
             
              def write_to_file
         
     | 
| 
       38 
     | 
    
         
            -
                parent = File.join(Rails.root, "public", "kit", self.file_type)
         
     | 
| 
      
 53 
     | 
    
         
            +
                parent = File.join(Rails.root, "public", "kit",  self.system_id.to_s, self.file_type)
         
     | 
| 
       39 
54 
     | 
    
         
             
                FileUtils.mkdir_p(parent) unless File.exists?(parent)
         
     | 
| 
       40 
55 
     | 
    
         | 
| 
       41 
     | 
    
         
            -
                path = File.join(Rails.root, "public", "kit", self.file_type, self.kit_name)
         
     | 
| 
       42 
     | 
    
         
            -
                dir = File.join(Rails.root, "public", "kit", self.file_type)
         
     | 
| 
      
 56 
     | 
    
         
            +
                path = File.join(Rails.root, "public", "kit", self.system_id.to_s, self.file_type, self.kit_name)
         
     | 
| 
      
 57 
     | 
    
         
            +
                dir = File.join(Rails.root, "public", "kit", self.system_id.to_s, self.file_type)
         
     | 
| 
       43 
58 
     | 
    
         
             
                found = false
         
     | 
| 
       44 
59 
     | 
    
         
             
                Dir.glob(dir + "/#{self.name.downcase}*") do |f|
         
     | 
| 
       45 
60 
     | 
    
         
             
                  if f==path
         
     | 
    
        data/app/models/layout.rb
    CHANGED
    
    | 
         @@ -1,9 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Layout < ActiveRecord::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
              has_many :html_assetable, :as=>:html_assetable
         
     | 
| 
      
 3 
     | 
    
         
            +
              has_many :html_assets, :through=>:html_assetable
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       2 
5 
     | 
    
         
             
              store_templates
         
     | 
| 
       3 
6 
     | 
    
         | 
| 
       4 
7 
     | 
    
         
             
              use_kit_caching
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
              attr_accessible :name, :handler, : 
     | 
| 
      
 9 
     | 
    
         
            +
              attr_accessible :name, :handler,  :body, :html_asset_ids, :path, :format, :locale, :system_id, :user_id
         
     | 
| 
       7 
10 
     | 
    
         
             
              before_save :make_path
         
     | 
| 
       8 
11 
     | 
    
         
             
              before_save :set_format
         
     | 
| 
       9 
12 
     | 
    
         
             
              has_many :page_templates
         
     | 
| 
         @@ -32,7 +35,7 @@ class Layout < ActiveRecord::Base 
     | 
|
| 
       32 
35 
     | 
    
         
             
              end
         
     | 
| 
       33 
36 
     | 
    
         | 
| 
       34 
37 
     | 
    
         
             
              def make_path
         
     | 
| 
       35 
     | 
    
         
            -
                self.path = "layouts 
     | 
| 
      
 38 
     | 
    
         
            +
                self.path = "layouts/#{self.system_id}/#{self.name.urlise}"
         
     | 
| 
       36 
39 
     | 
    
         
             
              end
         
     | 
| 
       37 
40 
     | 
    
         | 
| 
       38 
41 
     | 
    
         
             
              def set_format
         
     | 
| 
         @@ -47,15 +50,19 @@ class Layout < ActiveRecord::Base 
     | 
|
| 
       47 
50 
     | 
    
         
             
                ['haml', 'erb', 'builder']
         
     | 
| 
       48 
51 
     | 
    
         
             
              end
         
     | 
| 
       49 
52 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
              def self.name_exists?(name)
         
     | 
| 
       51 
     | 
    
         
            -
                Layout.where("name = '#{name}'").count > 0
         
     | 
| 
      
 53 
     | 
    
         
            +
              def self.name_exists?(sid, name)
         
     | 
| 
      
 54 
     | 
    
         
            +
                Layout.sys(sid).where("name = '#{name}'").count > 0
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              def self.default(sid) 
         
     | 
| 
      
 58 
     | 
    
         
            +
                Layout.sys(sid).order(:id).first
         
     | 
| 
       52 
59 
     | 
    
         
             
              end
         
     | 
| 
       53 
60 
     | 
    
         | 
| 
       54 
61 
     | 
    
         
             
              def self.create_default(sid, user_id)
         
     | 
| 
       55 
     | 
    
         
            -
                layout = Layout.new(: 
     | 
| 
      
 62 
     | 
    
         
            +
                layout = Layout.new(:path=>"layouts/#{sid}/application", :handler=>"haml", :format=>"html", :locale=>"en", :system_id=>sid, :user_id=>user_id, :name=>"application", :body=><<eos
         
     | 
| 
       56 
63 
     | 
    
         
             
            !!!
         
     | 
| 
       57 
64 
     | 
    
         
             
            %html
         
     | 
| 
       58 
     | 
    
         
            -
              / Layout: application 
     | 
| 
      
 65 
     | 
    
         
            +
              / Layout: application [#{sid}]
         
     | 
| 
       59 
66 
     | 
    
         
             
              %head
         
     | 
| 
       60 
67 
     | 
    
         
             
                = render :partial=>"layouts/kit_header"
         
     | 
| 
       61 
68 
     | 
    
         
             
                %style(type="text/css")
         
     | 
| 
         @@ -67,4 +74,27 @@ eos 
     | 
|
| 
       67 
74 
     | 
    
         | 
| 
       68 
75 
     | 
    
         
             
                layout.save!
         
     | 
| 
       69 
76 
     | 
    
         
             
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              def javascripts
         
     | 
| 
      
 79 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"js").all
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              def stylesheets
         
     | 
| 
      
 83 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"css").all
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
              
         
     | 
| 
      
 86 
     | 
    
         
            +
              def old_stylesheets
         
     | 
| 
      
 87 
     | 
    
         
            +
                self.read_attribute(:stylesheets)
         
     | 
| 
      
 88 
     | 
    
         
            +
              end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
              def old_javascripts
         
     | 
| 
      
 91 
     | 
    
         
            +
                self.read_attribute(:javascripts)
         
     | 
| 
      
 92 
     | 
    
         
            +
              end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              def self.preference(sid, name)
         
     | 
| 
      
 95 
     | 
    
         
            +
                l = Layout.sys(sid).where(:id=>Preference.get_cached(sid, name)).first rescue nil
         
     | 
| 
      
 96 
     | 
    
         
            +
                return l if l
         
     | 
| 
      
 97 
     | 
    
         
            +
                Layout.sys(sid).order("created_at").first
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
       70 
100 
     | 
    
         
             
            end
         
     | 
    
        data/app/models/newsletter.rb
    CHANGED
    
    
    
        data/app/models/page.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Page < KitIndexed
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
              attr_accessible :full_path, :category_id, :status_id, :name, :title, :page_template_id, :created_by, :updated_by, :system_id, :tags, :meta_description, :meta_keywords, :header
         
     | 
| 
      
 3 
     | 
    
         
            +
              attr_accessible :full_path, :category_id, :status_id, :name, :title, :page_template_id, :created_by, :updated_by, :system_id, :tags, :meta_description, :meta_keywords, :header, :status, :needs_crawl, :updated_crawl
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                @@index_def =  [
         
     | 
| 
       6 
6 
     | 
    
         
             
                  {:name=>:id, :index=>:not_analyzed, :include_in_all=>false},
         
     | 
| 
         @@ -15,7 +15,7 @@ class Page < KitIndexed 
     | 
|
| 
       15 
15 
     | 
    
         
             
                  {:name=>:terms, :as=>"concatenated_terms", :user=>true},
         
     | 
| 
       16 
16 
     | 
    
         
             
                  {:name=>:created_by, :as=>"user.email"},
         
     | 
| 
       17 
17 
     | 
    
         
             
                  {:name=>:updated_at, :type=>'date', :include_in_all=>false},
         
     | 
| 
       18 
     | 
    
         
            -
                  {:name=>:status, :as=>"status.name", :index=>:not_analyzed},
         
     | 
| 
      
 18 
     | 
    
         
            +
                  {:name=>:status, :as=>"status.name.downcase", :index=>:not_analyzed},
         
     | 
| 
       19 
19 
     | 
    
         
             
                  {:name=>:is_deleted, :index=>:not_analyzed},
         
     | 
| 
       20 
20 
     | 
    
         
             
                  {:name=>:content, :as=>"concatenated_content(:current)", :user=>true},
         
     | 
| 
       21 
21 
     | 
    
         
             
                  {:name=>:old_content, :as=>"concatenated_content(:old)", :include_in_all=>false},
         
     | 
| 
         @@ -93,6 +93,7 @@ class Page < KitIndexed 
     | 
|
| 
       93 
93 
     | 
    
         
             
                belongs_to :status
         
     | 
| 
       94 
94 
     | 
    
         
             
                belongs_to :user, :class_name=>"User", :foreign_key=>"created_by"
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
      
 96 
     | 
    
         
            +
                has_many :page_links
         
     | 
| 
       96 
97 
     | 
    
         
             
                has_many :comments
         
     | 
| 
       97 
98 
     | 
    
         
             
                has_many :block_instances, :dependent=>:destroy
         
     | 
| 
       98 
99 
     | 
    
         
             
                has_many :page_histories, :dependent=>:destroy
         
     | 
| 
         @@ -108,8 +109,10 @@ class Page < KitIndexed 
     | 
|
| 
       108 
109 
     | 
    
         
             
                before_save { self.name.downcase! }
         
     | 
| 
       109 
110 
     | 
    
         
             
                before_save :history_start
         
     | 
| 
       110 
111 
     | 
    
         
             
                before_save :change_full_path
         
     | 
| 
      
 112 
     | 
    
         
            +
                
         
     | 
| 
       111 
113 
     | 
    
         
             
                after_save :history_end
         
     | 
| 
       112 
114 
     | 
    
         
             
                after_save :clear_cache
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
       113 
116 
     | 
    
         
             
                after_destroy :clear_cache
         
     | 
| 
       114 
117 
     | 
    
         
             
                after_create :set_page_template_defaults
         
     | 
| 
       115 
118 
     | 
    
         | 
| 
         @@ -123,6 +126,37 @@ class Page < KitIndexed 
     | 
|
| 
       123 
126 
     | 
    
         
             
                validate :path_must_be_unique
         
     | 
| 
       124 
127 
     | 
    
         | 
| 
       125 
128 
     | 
    
         | 
| 
      
 129 
     | 
    
         
            +
                def full_url
         
     | 
| 
      
 130 
     | 
    
         
            +
                  "#{Preference.get_cached(self.system_id, "host")}#{self.full_path}"
         
     | 
| 
      
 131 
     | 
    
         
            +
                end
         
     | 
| 
      
 132 
     | 
    
         
            +
             
     | 
| 
      
 133 
     | 
    
         
            +
                def queue_crawl(start_crawl = true)
         
     | 
| 
      
 134 
     | 
    
         
            +
                  logger.debug "Queueing crawl for page #{self.id}"
         
     | 
| 
      
 135 
     | 
    
         
            +
                  self.needs_crawl = Time.now
         
     | 
| 
      
 136 
     | 
    
         
            +
                  self.save
         
     | 
| 
      
 137 
     | 
    
         
            +
                  Delayed::Job.enqueue PageLinkJob.new(self.system_id), :queue=>self.system_id if start_crawl
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
                def crawl(force = false)
         
     | 
| 
      
 141 
     | 
    
         
            +
                  return unless force || self.needs_crawl 
         
     | 
| 
      
 142 
     | 
    
         
            +
                  self.update_attributes(:needs_crawl=>nil)
         
     | 
| 
      
 143 
     | 
    
         
            +
                  PageLink.delete_all("page_id = #{self.id}")
         
     | 
| 
      
 144 
     | 
    
         
            +
                  
         
     | 
| 
      
 145 
     | 
    
         
            +
                  Anemone.crawl(full_url, :depth_limit=>1, :read_timeout=>2, :discard_page_bodies=>true) do |anemone|
         
     | 
| 
      
 146 
     | 
    
         
            +
                    first_page = true
         
     | 
| 
      
 147 
     | 
    
         
            +
                    anemone.on_every_page do |page|
         
     | 
| 
      
 148 
     | 
    
         
            +
                      if first_page
         
     | 
| 
      
 149 
     | 
    
         
            +
                        first_page = false
         
     | 
| 
      
 150 
     | 
    
         
            +
                        next
         
     | 
| 
      
 151 
     | 
    
         
            +
                      end
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
                      uri = URI.parse(page.url.to_s)
         
     | 
| 
      
 154 
     | 
    
         
            +
                      PageLink.create(:page_id=>self.id, :url=>uri.path, :http_status=>page.code, :system_id=>self.system_id)
         
     | 
| 
      
 155 
     | 
    
         
            +
                    end
         
     | 
| 
      
 156 
     | 
    
         
            +
                  end
         
     | 
| 
      
 157 
     | 
    
         
            +
                  self.update_attributes(:updated_crawl=>Time.now) 
         
     | 
| 
      
 158 
     | 
    
         
            +
                end      
         
     | 
| 
      
 159 
     | 
    
         
            +
             
     | 
| 
       126 
160 
     | 
    
         
             
                attr_writer :editable
         
     | 
| 
       127 
161 
     | 
    
         
             
                def editable
         
     | 
| 
       128 
162 
     | 
    
         
             
                  @editable || false
         
     | 
    
        data/app/models/page_template.rb
    CHANGED
    
    | 
         @@ -1,4 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class PageTemplate < ActiveRecord::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
              has_many :html_assetable, :as=>:html_assetable
         
     | 
| 
      
 3 
     | 
    
         
            +
              has_many :html_assets, :through=>:html_assetable
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       2 
5 
     | 
    
         
             
              has_many :pages
         
     | 
| 
       3 
6 
     | 
    
         
             
              belongs_to :layout
         
     | 
| 
       4 
7 
     | 
    
         
             
              has_and_belongs_to_many :blocks
         
     | 
| 
         @@ -6,7 +9,7 @@ class PageTemplate < ActiveRecord::Base 
     | 
|
| 
       6 
9 
     | 
    
         
             
              has_many :page_template_terms
         
     | 
| 
       7 
10 
     | 
    
         
             
              belongs_to :user
         
     | 
| 
       8 
11 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
              attr_accessible :name, :template_type, :layout_id, :allow_anonymous_comments, :allow_user_comments, :hidden, :is_mobile, :mobile_version_id, :body, : 
     | 
| 
      
 12 
     | 
    
         
            +
              attr_accessible :name, :template_type, :layout_id, :allow_anonymous_comments, :allow_user_comments, :hidden, :is_mobile, :mobile_version_id, :body, :system_id, :html_asset_ids, :header, :footer, :is_default, :page_type
         
     | 
| 
       10 
13 
     | 
    
         | 
| 
       11 
14 
     | 
    
         
             
              use_kit_caching
         
     | 
| 
       12 
15 
     | 
    
         | 
| 
         @@ -83,7 +86,24 @@ class PageTemplate < ActiveRecord::Base 
     | 
|
| 
       83 
86 
     | 
    
         
             
              end
         
     | 
| 
       84 
87 
     | 
    
         | 
| 
       85 
88 
     | 
    
         
             
              def self.create_default(sid, user_id)
         
     | 
| 
       86 
     | 
    
         
            -
                PageTemplate.create(:system_id=>sid, : 
     | 
| 
      
 89 
     | 
    
         
            +
                PageTemplate.create(:system_id=>sid, :header=>'', :footer=>'', :layout_id=>Layout.sys(sid).first.id, :template_type=>"haml", :is_mobile=>0, :is_default=>1, :page_type=>"default", :name=>"default", :body=>"= field('body')")
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              def javascripts
         
     | 
| 
      
 93 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"js").all
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              def stylesheets
         
     | 
| 
      
 97 
     | 
    
         
            +
                self.html_assets.where(:file_type=>"css").all
         
     | 
| 
       87 
98 
     | 
    
         
             
              end
         
     | 
| 
       88 
99 
     | 
    
         | 
| 
      
 100 
     | 
    
         
            +
              def old_stylesheets
         
     | 
| 
      
 101 
     | 
    
         
            +
                self.read_attribute(:stylesheets)
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              def old_javascripts
         
     | 
| 
      
 105 
     | 
    
         
            +
                self.read_attribute(:javascripts)
         
     | 
| 
      
 106 
     | 
    
         
            +
              end
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
              
         
     | 
| 
       89 
109 
     | 
    
         
             
            end
         
     | 
    
        data/app/models/preference.rb
    CHANGED
    
    | 
         @@ -75,7 +75,7 @@ class Preference < ActiveRecord::Base 
     | 
|
| 
       75 
75 
     | 
    
         
             
              end
         
     | 
| 
       76 
76 
     | 
    
         | 
| 
       77 
77 
     | 
    
         
             
              def Preference.licensed?(sid, name)
         
     | 
| 
       78 
     | 
    
         
            -
                licensed = Rails.cache.fetch("licenses_#{sid}_#{name}", :expires_in=> 
     | 
| 
      
 78 
     | 
    
         
            +
                licensed = Rails.cache.fetch("licenses_#{sid}_#{name}", :expires_in=>1.minutes) do 
         
     | 
| 
       79 
79 
     | 
    
         
             
                  Preference.get_cached(sid, "feature_#{name}")=="true" || Preference.get_cached(sid, "feature_*")=="true"
         
     | 
| 
       80 
80 
     | 
    
         
             
                end
         
     | 
| 
       81 
81 
     | 
    
         | 
| 
         @@ -0,0 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class QMessage < ActiveRecord::Base
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
              attr_accessible  :q_publisher, :q_publisher_id, :q_event, :q_subscription, :q_user, :system_id , :status, :body, :h1, :h2
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              belongs_to :q_publisher
         
     | 
| 
      
 6 
     | 
    
         
            +
              belongs_to :q_user
         
     | 
| 
      
 7 
     | 
    
         
            +
              belongs_to :q_event
         
     | 
| 
      
 8 
     | 
    
         
            +
              belongs_to :q_subscription
         
     | 
| 
      
 9 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'bcrypt'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'digest/md5'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            class QPublisher < ActiveRecord::Base
         
     | 
| 
      
 5 
     | 
    
         
            +
              include BCrypt
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
              attr_accessible :name, :token, :auth_method, :auth_id, :encrypted_auth_secret, :auth_secret, :twitter_consumer_key, :twitter_consumer_secret, :twitter_oauth_token, :twitter_oauth_token_secret, :mail_from
         
     | 
| 
      
 8 
     | 
    
         
            +
              belongs_to :system
         
     | 
| 
      
 9 
     | 
    
         
            +
              has_many :q_subscriptions, :dependent => :destroy
         
     | 
| 
      
 10 
     | 
    
         
            +
              has_many :q_users_publishers, :dependent=>:destroy
         
     | 
| 
      
 11 
     | 
    
         
            +
              has_many :q_users, :through=>:q_users_publishers
         
     | 
| 
      
 12 
     | 
    
         
            +
              has_many :q_events, :dependent => :destroy
         
     | 
| 
      
 13 
     | 
    
         
            +
              has_many :q_klasses, :dependent => :destroy
         
     | 
| 
      
 14 
     | 
    
         
            +
              has_many :q_messages, :dependent => :destroy
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def auth_secret
         
     | 
| 
      
 17 
     | 
    
         
            +
                @auth_secret ||= Password.new(encrypted_auth_secret)
         
     | 
| 
      
 18 
     | 
    
         
            +
              end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def auth_secret=(new_secret)
         
     | 
| 
      
 21 
     | 
    
         
            +
                @auth_secret = Password.create(new_secret)
         
     | 
| 
      
 22 
     | 
    
         
            +
                self.encrypted_auth_secret = @auth_secret
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              def generate_auth_secret
         
     | 
| 
      
 26 
     | 
    
         
            +
                gen = QPublisher.generate_random
         
     | 
| 
      
 27 
     | 
    
         
            +
                puts "Generate auth secret: #{gen}"
         
     | 
| 
      
 28 
     | 
    
         
            +
                self.auth_secret = gen
         
     | 
| 
      
 29 
     | 
    
         
            +
                self.save
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              def QPublisher.generate_random
         
     | 
| 
      
 33 
     | 
    
         
            +
                Digest::MD5.hexdigest(Time.now.to_s + rand(10000000).to_s)
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     |