site_logic 1.9.2 → 1.9.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'http://rubygems.org'
2
- source 'http://jose.seologic.com:8808/'
3
2
 
4
3
  gem 'bson_ext'
5
4
  gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
@@ -9,6 +8,7 @@ gem 'mongoid-tree', :require => 'mongoid/tree'
9
8
  gem 'rails', '3.0.10'
10
9
  gem 'rmagick', '2.12.2' # version compatible with heroku
11
10
  gem 'scaffold_logic', '>= 1.0.3'
11
+ gem 'stringex'
12
12
  gem 'SystemTimer'
13
13
  gem 'tanker'
14
14
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.2
1
+ 1.9.3
@@ -1,11 +1,11 @@
1
1
  class NavItem
2
-
3
2
  include Mongoid::Document
4
3
  include Mongoid::Timestamps
5
- include SiteLogic::Base
6
4
 
7
- # Attributes =====================================================================================
5
+ # Constants ======================================================================================
6
+ KINDS = ['Main', 'Secondary', 'Footer']
8
7
 
8
+ # Mongoid ========================================================================================
9
9
  field :link_title
10
10
  field :link_text
11
11
  field :url
@@ -13,39 +13,24 @@ class NavItem
13
13
  field :position, :type => Integer
14
14
  field :obfuscate, :type => Boolean
15
15
  field :kind
16
-
17
- # Indices ========================================================================================
18
-
19
- # Scopes =========================================================================================
16
+ embedded_in :site, :inverse_of => :nav_items
20
17
  scope :roots, :where => {:parent_id => nil}
21
18
  scope :primary, :where => {:kind => 'Main'}
22
19
  scope :secondary, :where => {:kind => 'Secondary'}
23
20
  scope :footer, :where => {:kind => 'Footer'}
24
21
 
25
- # Relationships ==================================================================================
26
- embedded_in :site, :inverse_of => :nav_items
27
-
28
22
  # Behavior =======================================================================================
29
23
  attr_accessor :status
30
24
  attr_accessor :creating_page
31
25
 
32
- # Constants ======================================================================================
33
-
34
- KINDS = ["Main", "Secondary", "Footer"]
35
-
36
- # Callbacks ======================================================================================
37
-
38
26
  # Validations ====================================================================================
39
27
  validates_presence_of :link_text
40
28
  validates_presence_of :link_title
41
29
  validates_presence_of :url
42
30
 
43
- # Class methods ==================================================================================
44
-
45
31
  # Instance methods ===============================================================================
46
-
47
32
  def children
48
- self.site.nav_items.select{|ni| ni.parent_id == self.id.to_s}.sort{|a,b| a.position.to_i <=> b.position.to_i}
33
+ self.site.nav_items.select{|ni| ni.parent_id == self.id.to_s}.sort_by{|ni| ni.position.to_i}
49
34
  end
50
35
 
51
36
  def decoded_url
@@ -53,7 +38,7 @@ class NavItem
53
38
  end
54
39
 
55
40
  def encoded_url
56
- self[:url].gsub("/","#").tr("A-Ma-mN-Zn-z","N-Zn-zA-Ma-m")
41
+ self[:url].gsub('/', '#').tr('A-Ma-mN-Zn-z', 'N-Zn-zA-Ma-m')
57
42
  end
58
43
 
59
44
  def omit_from_sitemap?
@@ -61,7 +46,7 @@ class NavItem
61
46
  end
62
47
 
63
48
  def parent
64
- self.site.nav_items.find(self.parent_id)
49
+ self.site.nav_items.find self.parent_id
65
50
  end
66
51
 
67
52
  def root?
@@ -79,5 +64,4 @@ class NavItem
79
64
  def url
80
65
  @url = self.obfuscate? ? encoded_url : self[:url]
81
66
  end
82
-
83
- end
67
+ end
data/app/models/page.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  class Page
2
+ include LuckySneaks::StringExtensions
2
3
  include Mongoid::Document
3
4
  include Mongoid::Timestamps
4
- include SiteLogic::Base
5
5
  include Tanker
6
6
 
7
7
  # Constants ======================================================================================
@@ -33,8 +33,9 @@ class Page
33
33
 
34
34
  # Behavior =======================================================================================
35
35
  attr_accessor :create_navigation_item
36
- attr_accessor :desired_slug
37
- has_slug :desired_slug
36
+ before_save :set_slug
37
+ validates_presence_of :content, :page_title
38
+ validates_uniqueness_of :slug
38
39
 
39
40
  # Tanker =========================================================================================
40
41
  tankit 'idx' do
@@ -47,31 +48,22 @@ class Page
47
48
  after_destroy :delete_tank_indexes
48
49
  after_save :update_tank_indexes
49
50
 
50
- # Validations ====================================================================================
51
- class DesiredSlugPresenceAndUniquenessValidator < ActiveModel::EachValidator
52
- def validate_each(object, attribute, value)
53
- return unless object.desired_slug
54
- if object.site && object.site.pages.map{|p| p.slug unless p == object}.include?(object.desired_slug)
55
- object.errors[attribute] << (options[:message] || 'must be unique.')
56
- end
57
- end
58
- end
59
-
60
- validates :desired_slug, :desired_slug_presence_and_uniqueness => true
61
- validates_presence_of :page_title
62
- validates_presence_of :content
63
-
64
51
  # Instance methods ===============================================================================
65
52
  def draft?
66
53
  self.state == 'draft' || self.state.nil?
67
54
  end
68
55
 
56
+ # @deprecated Please use {#path} instead
69
57
  def humanize_path
58
+ warn "[DEPRECATION] `humanize_path` is deprecated. Please use `path` instead."
70
59
  self.path
71
60
  end
72
61
 
62
+ # Returns this page's path.
63
+ #
64
+ # @return [String] the path for this page
73
65
  def path
74
- self.slug == '' ? '/' : "/#{self.slug}".gsub(/\/\//,'/').gsub(/\/\//,'/')
66
+ self.slug == '' ? '/' : "/#{self.slug}".gsub('//', '/')
75
67
  end
76
68
 
77
69
  def publish!
@@ -105,4 +97,10 @@ class Page
105
97
  def window_title
106
98
  self[:window_title] || self.page_title
107
99
  end
100
+
101
+ private
102
+
103
+ def set_slug
104
+ self.slug = (self.window_title || self.page_title).to_s.to_url if self.slug.blank?
105
+ end
108
106
  end
@@ -1,39 +1,19 @@
1
1
  class Redirect
2
-
3
2
  include Mongoid::Document
4
3
  include Mongoid::Timestamps
5
- include SiteLogic::Base
6
-
7
- # Attributes =====================================================================================
8
4
 
5
+ # Mongoid ========================================================================================
9
6
  field :source_url
10
7
  field :destination_url
11
-
12
- # Indices ========================================================================================
13
8
  index :source_url, :unique => true
14
-
15
- # Constants ======================================================================================
16
-
17
- # Scopes ===================================================================================
18
-
19
- # Relationships ==================================================================================
20
9
  embedded_in :site, :inverse_of => :redirects
21
10
 
22
11
  # Behavior =======================================================================================
23
-
24
- # Callbacks ======================================================================================
25
-
26
- # Validations ====================================================================================
27
- validates_presence_of :source_url
28
- validates_presence_of :destination_url
12
+ validates_presence_of :destination_url, :source_url
29
13
  validates_uniqueness_of :source_url
30
14
 
31
- # Class methods ==================================================================================
32
-
33
15
  # Instance methods ===============================================================================
34
-
35
- def source_url=(url)
36
- self[:source_url] = url.gsub(/^http:\/\/.+\.#{self.site.try(:domain)}/,'')
16
+ def source_url= url
17
+ self[:source_url] = url.gsub /^http:\/\/.+\.#{self.site.try(:domain)}/, ''
37
18
  end
38
-
39
- end
19
+ end
data/app/models/site.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  class Site
2
-
3
2
  include Mongoid::Document
4
3
  include Mongoid::Timestamps
5
- include SiteLogic::Base
6
4
 
7
- # Attributes =====================================================================================
5
+ # Constants ======================================================================================
6
+ STATES = ['inactive', 'active']
8
7
 
8
+ # Scopes ===================================================================================
9
+ scope :active, :where => {:state => 'active'}
10
+ scope :inactive, :where => {:state => 'inactive'}
11
+
12
+ # Mongoid ========================================================================================
9
13
  field :domain
10
14
  field :name
11
15
  field :layout
@@ -17,58 +21,41 @@ class Site
17
21
  field :bing_webmaster_code
18
22
  field :netinsert_code
19
23
  field :activation_date, :type => DateTime
20
-
21
- # Indices ========================================================================================
22
24
  index :domain, :unique => true
23
25
  index :name, :unique => true
24
-
25
- # Constants ======================================================================================
26
- STATES = ['inactive', 'active']
27
-
28
- # Scopes ===================================================================================
29
- scope :active, :where => {:state => 'active'}
30
- scope :inactive, :where => {:state => 'inactive'}
31
-
32
- # Relationships ==================================================================================
33
26
  embeds_many :pages
34
27
  embeds_many :nav_items
35
28
  embeds_many :redirects
36
29
 
37
30
  # Behavior =======================================================================================
38
31
  attr_accessor :status
39
-
40
- # Callbacks ======================================================================================
41
-
42
- # Validations ====================================================================================
43
32
  validates_presence_of :domain
44
33
  validates_uniqueness_of :domain
45
34
  validates_presence_of :name
46
35
  validates_uniqueness_of :name
47
36
 
48
37
  # Class methods ==================================================================================
49
-
50
38
  def self.layouts
51
39
  basedir = "#{Rails.root.to_s}/app/views/layouts/"
52
- files = Dir.glob("#{Rails.root.to_s}/app/views/layouts/*.html.erb")
40
+ files = Dir.glob "#{Rails.root.to_s}/app/views/layouts/*.html.erb"
53
41
  files.map{|f| f.gsub(/.+layouts\/(.+)\.html.erb/, '\1')}
54
42
  end
55
43
 
56
44
  # Instance methods ===============================================================================
57
-
58
45
  def active?
59
- self.state == "active"
46
+ self.state == 'active'
60
47
  end
61
48
 
62
49
  def activate!
63
- self.update_attributes(:state => 'active', :activation_date => Time.zone.now)
50
+ self.update_attributes :state => 'active', :activation_date => Time.zone.now
64
51
  end
65
52
 
66
53
  def deactivate!
67
- self.update_attributes(:state => 'inactive', :activation_date => nil)
54
+ self.update_attributes :state => 'inactive', :activation_date => nil
68
55
  end
69
56
 
70
57
  def footer_navigation
71
- self.nav_items.roots.footer.sort{|a,b| a.position.to_i <=> b.position.to_i}
58
+ self.nav_items.roots.footer.sort_by{|a| a.position.to_i}
72
59
  end
73
60
 
74
61
  def home_page
@@ -76,15 +63,15 @@ class Site
76
63
  end
77
64
 
78
65
  def inactive?
79
- self.state != "active"
66
+ ! self.active?
80
67
  end
81
68
 
82
69
  def primary_navigation
83
- self.nav_items.roots.primary.sort{|a,b| a.position.to_i <=> b.position.to_i}
70
+ self.nav_items.roots.primary.sort_by{|a| a.position.to_i}
84
71
  end
85
72
 
86
73
  def secondary_navigation
87
- self.nav_items.roots.secondary.sort{|a,b| a.position.to_i <=> b.position.to_i}
74
+ self.nav_items.roots.secondary.sort_by{|a| a.position.to_i}
88
75
  end
89
76
 
90
77
  def state
@@ -94,5 +81,4 @@ class Site
94
81
  def status
95
82
  self.state.capitalize
96
83
  end
97
-
98
- end
84
+ end
@@ -21,7 +21,7 @@
21
21
  <div class="form_column">
22
22
  <%= f.text_field :page_title, :label => 'Page Header', :help => 'This title will appear on the page before any content, and is used by search engines to identify the main idea of the page.' -%>
23
23
  <%= f.text_field :window_title, :label => 'Title Tag', :help => 'This title appears at the top of the browser window and is used by search engine spiders to uniquely identify a given page.' -%>
24
- <%= f.text_field :desired_slug, :help => "The permalink forms part of the URL for this page. For example, entering my-page will create the URL 'http://www.#{@site.domain}/my-page/'.", :label => 'Permalink', :value => @page.slug || '/'-%>
24
+ <%= f.text_field :slug, :help => "The slug forms part of the URL for this page. For example, entering my-page will create the URL 'http://www.#{@site.domain}/my-page/'." -%>
25
25
  <%= f.select :state, Page::STATES.map{|s| s.capitalize}, :selected => @page.status, :label => 'Status', :help => 'Content may either be in a published or draft state. Draft content can be previewed but will not appear on the public-facing web site.' -%>
26
26
  </div>
27
27
  <div class="form_column">
data/init.rb CHANGED
@@ -1 +1 @@
1
- require 'site_logic'
1
+ require 'site_logic'
@@ -1,15 +1,10 @@
1
1
  module SiteLogic
2
-
3
2
  class Navigation
4
-
5
3
  attr_accessor :kind
6
4
  attr_accessor :label
7
5
  attr_accessor :description
8
-
9
6
  def initialize(args)
10
7
  args.each{|k,v| self.send("#{k}=",v) if self.respond_to?(k)}
11
8
  end
12
-
13
9
  end
14
-
15
10
  end
@@ -1,5 +1,3 @@
1
- require 'site_logic'
2
- require 'rails'
3
1
  module SiteLogic
4
2
  class Railtie < Rails::Railtie
5
3
  rake_tasks do
data/lib/site_logic.rb CHANGED
@@ -1,14 +1,17 @@
1
1
  module SiteLogic
2
- require 'site_logic/engine' if defined?(Rails)
3
- require 'site_logic/railtie' if defined?(Rails)
4
- require 'site_logic/base'
5
2
  require 'site_logic/navigation'
3
+ require 'site_logic/railtie' if defined?(Rails)
6
4
 
7
5
  mattr_accessor :navigation_options
8
6
  mattr_accessor :primary_nav
9
7
  mattr_accessor :secondary_nav
10
8
  mattr_accessor :footer_nav
11
9
 
10
+ module SiteLogic
11
+ class Engine < Rails::Engine
12
+ end
13
+ end
14
+
12
15
  def self.setup
13
16
  yield self
14
17
  end
data/site_logic.gemspec CHANGED
@@ -5,22 +5,17 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "site_logic"
8
- s.version = "1.9.2"
8
+ s.version = "1.9.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bantik"]
12
- s.date = "2011-09-28"
12
+ s.date = "2011-11-01"
13
13
  s.description = "An engine for search-engine-optimized content management."
14
14
  s.email = "corey@seologic.com"
15
- s.extra_rdoc_files = [
16
- "README.rdoc"
17
- ]
18
15
  s.files = [
19
16
  ".document",
20
17
  ".rspec",
21
- "Capfile",
22
18
  "Gemfile",
23
- "README.rdoc",
24
19
  "Rakefile",
25
20
  "VERSION",
26
21
  "app/controllers/admin/nav_items_controller.rb",
@@ -72,7 +67,6 @@ Gem::Specification.new do |s|
72
67
  "config/application.rb",
73
68
  "config/boot.rb",
74
69
  "config/cucumber.yml",
75
- "config/deploy.rb",
76
70
  "config/environment.rb",
77
71
  "config/environments/development.rb",
78
72
  "config/environments/production.rb",
@@ -81,7 +75,6 @@ Gem::Specification.new do |s|
81
75
  "config/initializers/metric_fu.rb",
82
76
  "config/initializers/secret_token.rb",
83
77
  "config/initializers/session_store.rb",
84
- "config/locales/en.yml",
85
78
  "config/mongoid.yml",
86
79
  "config/routes.rb",
87
80
  "doc/TODO",
@@ -94,15 +87,10 @@ Gem::Specification.new do |s|
94
87
  "features/support/paths.rb",
95
88
  "init.rb",
96
89
  "lib/site_logic.rb",
97
- "lib/site_logic/base.rb",
98
- "lib/site_logic/engine.rb",
99
90
  "lib/site_logic/navigation.rb",
100
91
  "lib/site_logic/railtie.rb",
101
92
  "lib/tasks/cucumber.rake",
102
93
  "lib/tasks/rcov.rake",
103
- "public/404.html",
104
- "public/422.html",
105
- "public/500.html",
106
94
  "public/favicon.ico",
107
95
  "public/images/icons/add.png",
108
96
  "public/images/icons/collapsed.gif",
@@ -793,10 +781,8 @@ Gem::Specification.new do |s|
793
781
  "public/javascripts/controls.js",
794
782
  "public/javascripts/dragdrop.js",
795
783
  "public/javascripts/effects.js",
796
- "public/javascripts/link_obfuscator.js",
797
784
  "public/javascripts/prototype.js",
798
785
  "public/javascripts/rails.js",
799
- "public/robots.txt",
800
786
  "public/stylesheets/.gitkeep",
801
787
  "public/stylesheets/application.css",
802
788
  "public/stylesheets/core.css",
@@ -835,6 +821,7 @@ Gem::Specification.new do |s|
835
821
  s.add_runtime_dependency(%q<rails>, ["= 3.0.10"])
836
822
  s.add_runtime_dependency(%q<rmagick>, ["= 2.12.2"])
837
823
  s.add_runtime_dependency(%q<scaffold_logic>, [">= 1.0.3"])
824
+ s.add_runtime_dependency(%q<stringex>, [">= 0"])
838
825
  s.add_runtime_dependency(%q<SystemTimer>, [">= 0"])
839
826
  s.add_runtime_dependency(%q<tanker>, [">= 0"])
840
827
  s.add_development_dependency(%q<jeweler>, [">= 0"])
@@ -848,6 +835,7 @@ Gem::Specification.new do |s|
848
835
  s.add_dependency(%q<rails>, ["= 3.0.10"])
849
836
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
850
837
  s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
838
+ s.add_dependency(%q<stringex>, [">= 0"])
851
839
  s.add_dependency(%q<SystemTimer>, [">= 0"])
852
840
  s.add_dependency(%q<tanker>, [">= 0"])
853
841
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -862,6 +850,7 @@ Gem::Specification.new do |s|
862
850
  s.add_dependency(%q<rails>, ["= 3.0.10"])
863
851
  s.add_dependency(%q<rmagick>, ["= 2.12.2"])
864
852
  s.add_dependency(%q<scaffold_logic>, [">= 1.0.3"])
853
+ s.add_dependency(%q<stringex>, [">= 0"])
865
854
  s.add_dependency(%q<SystemTimer>, [">= 0"])
866
855
  s.add_dependency(%q<tanker>, [">= 0"])
867
856
  s.add_dependency(%q<jeweler>, [">= 0"])
data/spec/blueprints.rb CHANGED
@@ -1,21 +1,16 @@
1
- require 'machinist/mongoid'
2
- require 'sham'
3
- require 'faker'
4
-
5
- Site.blueprint do
6
- name { Faker::Lorem.words(5) * " " }
7
- domain { "www#{rand(1000)}.#{Faker::Internet.domain_name}" }
8
- end
9
-
10
1
  Page.blueprint do
11
- page_title { Faker::Lorem.words(5) * " " }
12
- slug { Faker::Lorem.words(5) * "_" }
13
- content { "Some content" }
2
+ page_title { Faker::Lorem.words(5) * ' ' }
3
+ content { 'Some content' }
14
4
  end
15
5
 
16
6
  NavItem.blueprint do
17
7
  kind { 'Primary' }
18
- url { Faker::Lorem.words(5) * "_" }
19
- link_text { Faker::Lorem.words(5) * " " }
20
- link_title { Faker::Lorem.words(5) * " " }
8
+ url { Faker::Lorem.words(5) * '_' }
9
+ link_text { Faker::Lorem.words(5) * ' ' }
10
+ link_title { Faker::Lorem.words(5) * ' ' }
11
+ end
12
+
13
+ Site.blueprint do
14
+ name { Faker::Lorem.words(5) * ' ' }
15
+ domain { "www#{rand(1000)}.#{Faker::Internet.domain_name}" }
21
16
  end
@@ -1,10 +1,10 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Admin::PagesController do
4
4
  before :all do
5
5
  Site.destroy_all
6
6
  @site = Site.make
7
- @page = @site.pages.create(:page_title => 'Vampire Bunnies', :desired_slug => 'bunnicula', :content => 'Scary monsters.')
7
+ @page = @site.pages.create :page_title => 'Vampire Bunnies', :content => 'Scary monsters.'
8
8
  end
9
9
 
10
10
  it "show action should render show template" do
@@ -40,7 +40,7 @@ describe Admin::PagesController do
40
40
  end
41
41
 
42
42
  it "update action should redirect when model is valid" do
43
- put :update, :id => @page.id, :site_id => @site.id.to_s, :page => {:desired_slug => 'foozball'}
43
+ put :update, :id => @page.id, :site_id => @site.id.to_s, :page => {:page_title => 'foozball'}
44
44
  response.should redirect_to(admin_site_pages_url(@site))
45
45
  end
46
46
 
@@ -1,11 +1,11 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Admin::RedirectsController do
4
4
  before :all do
5
5
  Site.destroy_all
6
6
  @site = Site.make
7
- @page = @site.pages.create(:page_title => 'Vampire Bunnies', :desired_slug => 'bunnicula', :content => 'Scary monsters.')
8
- @redirect = @site.redirects.create(:source_url => 'foo', :destination_url => 'bar')
7
+ @page = @site.pages.create :page_title => 'Vampire Bunnies', :content => 'Scary monsters.'
8
+ @redirect = @site.redirects.create :source_url => 'foo', :destination_url => 'bar'
9
9
  end
10
10
 
11
11
  it "index action should render index template" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Admin::SitesController do
4
4
  before :all do
@@ -1,15 +1,14 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe PagesController do
4
4
  before :all do
5
5
  Site.destroy_all
6
6
  @site = Site.make
7
- @page = @site.pages.create(:page_title => 'Vampire Bunnies', :desired_slug => '/bunnicula/', :content => 'Scary monsters.', :state => 'published')
7
+ @page = @site.pages.create :page_title => 'Vampire Bunnies', :content => 'Scary monsters.', :state => 'published'
8
8
  end
9
9
 
10
- it "show action should render show template" do
10
+ it 'show action should render show template' do
11
11
  get :show, :page_slug => '/bunnicula/'
12
12
  response.should render_template(:show)
13
13
  end
14
-
15
- end
14
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe NavItem do
4
4
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Page do
4
4
  before :all do
@@ -12,11 +12,12 @@ describe Page do
12
12
  end
13
13
 
14
14
  it 'should be valid with required values' do
15
- @site.pages.new(
15
+ page = @site.pages.new(
16
16
  :page_title => 'Home',
17
- :desired_slug => 'home',
18
17
  :content => 'Welcome home.'
19
- ).should be_valid
18
+ )
19
+ page.send :set_slug
20
+ page.should be_valid
20
21
  end
21
22
 
22
23
  it 'should not allow duplicate slugs' do
@@ -27,7 +28,6 @@ describe Page do
27
28
  )
28
29
  @site.pages.create(
29
30
  :page_title => 'Bar',
30
- :desired_slug => 'foo',
31
31
  :content => 'Welcome to bar.'
32
32
  ).should_not be_valid
33
33
  end
@@ -50,7 +50,6 @@ describe Page do
50
50
  it 'publishes a page, setting the publication date' do
51
51
  page = @site.pages.create(
52
52
  :page_title => 'Stiff',
53
- :desired_slug => 'corpse',
54
53
  :content => 'Dead stuff.'
55
54
  )
56
55
  page.publish!
@@ -62,7 +61,6 @@ describe Page do
62
61
  it 'unpublishes a page, clearing the publication date' do
63
62
  page = @site.pages.create(
64
63
  :page_title => 'Stuff',
65
- :desired_slug => 'detritus',
66
64
  :content => 'Random stuff.'
67
65
  )
68
66
  page.publish!
@@ -74,31 +72,31 @@ describe Page do
74
72
  end
75
73
 
76
74
  describe 'slug' do
77
- it 'is generated based on the desired_slug' do
78
- page = @site.pages.create(
75
+ it 'is generated based on the title' do
76
+ page = @site.pages.new(
79
77
  :page_title => 'Snakes',
80
- :desired_slug => 'snakes and stuff',
81
78
  :content => 'Random stuff.'
82
79
  )
83
- page.slug.should == 'snakes-and-stuff'
80
+ page.send :set_slug
81
+ page.slug.should == 'snakes'
84
82
  end
85
83
 
86
84
  it 'truncates extra hyphens' do
87
- page = @site.pages.create(
85
+ page = @site.pages.new(
88
86
  :page_title => 'Spiders',
89
- :desired_slug => 'spiders!! and stuff',
90
87
  :content => 'Random stuff.'
91
88
  )
92
- page.slug.should == 'spiders-and-stuff'
89
+ page.send :set_slug
90
+ page.slug.should == 'spiders'
93
91
  end
94
92
 
95
93
  it 'truncates trailing hyphens' do
96
- page = @site.pages.create(
94
+ page = @site.pages.new(
97
95
  :page_title => 'Sinews',
98
- :desired_slug => 'sinews? really?',
99
96
  :content => 'Random stuff.'
100
97
  )
101
- page.slug.should == 'sinews-really'
98
+ page.send :set_slug
99
+ page.slug.should == 'sinews'
102
100
  end
103
101
  end
104
102
 
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Redirect do
4
4
  it "should be valid" do
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Site do
4
4
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_logic
3
3
  version: !ruby/object:Gem::Version
4
- hash: 55
4
+ hash: 53
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 9
9
- - 2
10
- version: 1.9.2
9
+ - 3
10
+ version: 1.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bantik
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-28 00:00:00 Z
18
+ date: 2011-11-01 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: bson_ext
@@ -140,7 +140,7 @@ dependencies:
140
140
  type: :runtime
141
141
  version_requirements: *id008
142
142
  - !ruby/object:Gem::Dependency
143
- name: SystemTimer
143
+ name: stringex
144
144
  prerelease: false
145
145
  requirement: &id009 !ruby/object:Gem::Requirement
146
146
  none: false
@@ -154,7 +154,7 @@ dependencies:
154
154
  type: :runtime
155
155
  version_requirements: *id009
156
156
  - !ruby/object:Gem::Dependency
157
- name: tanker
157
+ name: SystemTimer
158
158
  prerelease: false
159
159
  requirement: &id010 !ruby/object:Gem::Requirement
160
160
  none: false
@@ -168,7 +168,7 @@ dependencies:
168
168
  type: :runtime
169
169
  version_requirements: *id010
170
170
  - !ruby/object:Gem::Dependency
171
- name: jeweler
171
+ name: tanker
172
172
  prerelease: false
173
173
  requirement: &id011 !ruby/object:Gem::Requirement
174
174
  none: false
@@ -179,12 +179,26 @@ dependencies:
179
179
  segments:
180
180
  - 0
181
181
  version: "0"
182
- type: :development
182
+ type: :runtime
183
183
  version_requirements: *id011
184
184
  - !ruby/object:Gem::Dependency
185
- name: rspec
185
+ name: jeweler
186
186
  prerelease: false
187
187
  requirement: &id012 !ruby/object:Gem::Requirement
188
+ none: false
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ hash: 3
193
+ segments:
194
+ - 0
195
+ version: "0"
196
+ type: :development
197
+ version_requirements: *id012
198
+ - !ruby/object:Gem::Dependency
199
+ name: rspec
200
+ prerelease: false
201
+ requirement: &id013 !ruby/object:Gem::Requirement
188
202
  none: false
189
203
  requirements:
190
204
  - - ">="
@@ -196,21 +210,19 @@ dependencies:
196
210
  - 9
197
211
  version: 1.2.9
198
212
  type: :development
199
- version_requirements: *id012
213
+ version_requirements: *id013
200
214
  description: An engine for search-engine-optimized content management.
201
215
  email: corey@seologic.com
202
216
  executables: []
203
217
 
204
218
  extensions: []
205
219
 
206
- extra_rdoc_files:
207
- - README.rdoc
220
+ extra_rdoc_files: []
221
+
208
222
  files:
209
223
  - .document
210
224
  - .rspec
211
- - Capfile
212
225
  - Gemfile
213
- - README.rdoc
214
226
  - Rakefile
215
227
  - VERSION
216
228
  - app/controllers/admin/nav_items_controller.rb
@@ -262,7 +274,6 @@ files:
262
274
  - config/application.rb
263
275
  - config/boot.rb
264
276
  - config/cucumber.yml
265
- - config/deploy.rb
266
277
  - config/environment.rb
267
278
  - config/environments/development.rb
268
279
  - config/environments/production.rb
@@ -271,7 +282,6 @@ files:
271
282
  - config/initializers/metric_fu.rb
272
283
  - config/initializers/secret_token.rb
273
284
  - config/initializers/session_store.rb
274
- - config/locales/en.yml
275
285
  - config/mongoid.yml
276
286
  - config/routes.rb
277
287
  - doc/TODO
@@ -284,15 +294,10 @@ files:
284
294
  - features/support/paths.rb
285
295
  - init.rb
286
296
  - lib/site_logic.rb
287
- - lib/site_logic/base.rb
288
- - lib/site_logic/engine.rb
289
297
  - lib/site_logic/navigation.rb
290
298
  - lib/site_logic/railtie.rb
291
299
  - lib/tasks/cucumber.rake
292
300
  - lib/tasks/rcov.rake
293
- - public/404.html
294
- - public/422.html
295
- - public/500.html
296
301
  - public/favicon.ico
297
302
  - public/images/icons/add.png
298
303
  - public/images/icons/collapsed.gif
@@ -983,10 +988,8 @@ files:
983
988
  - public/javascripts/controls.js
984
989
  - public/javascripts/dragdrop.js
985
990
  - public/javascripts/effects.js
986
- - public/javascripts/link_obfuscator.js
987
991
  - public/javascripts/prototype.js
988
992
  - public/javascripts/rails.js
989
- - public/robots.txt
990
993
  - public/stylesheets/.gitkeep
991
994
  - public/stylesheets/application.css
992
995
  - public/stylesheets/core.css
@@ -1042,3 +1045,4 @@ specification_version: 3
1042
1045
  summary: An engine for search-engine-optimized content management.
1043
1046
  test_files: []
1044
1047
 
1048
+ has_rdoc:
data/Capfile DELETED
@@ -1,4 +0,0 @@
1
- load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
- Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3
-
4
- load 'config/deploy' # remove this line to skip loading any of the default tasks
data/README.rdoc DELETED
@@ -1,17 +0,0 @@
1
- = site_logic
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
- * Send me a pull request. Bonus points for topic branches.
14
-
15
- == Copyright
16
-
17
- Copyright (c) 2010 Bantik. See LICENSE for details.
data/config/deploy.rb DELETED
@@ -1,40 +0,0 @@
1
- # Deploy this gem to the gem server.
2
- #
3
- # Usage for a gem already on the gem server:
4
- #
5
- # cap deploy
6
- #
7
- # For a new gem:
8
- #
9
- # cap deploy:new
10
-
11
- # Global Variables =================================================================================
12
- default_run_options[:pty] = true
13
- role :app, 'jose.seologic.com'
14
- set :deploy_to, '/home/containers/rails/system/site_logic'
15
- set :repository, 'git@github.com:ivanoblomov/site_logic.git'
16
- set :scm, :git
17
- set :use_sudo, false
18
- set :user, 'cnewton'
19
-
20
- namespace :deploy do
21
- desc "Clone a new gem's repository on the gem server."
22
- task :new do
23
- run "git clone -q #{repository} #{deploy_to}"
24
- end
25
-
26
- task :install do
27
- run "cd #{deploy_to}; rm -f Gemfile.lock; sudo bundle; sudo rake install"
28
- end
29
-
30
- # disable default behavior
31
- task :restart do
32
- end
33
-
34
- task :update do
35
- run "cd #{deploy_to}; git pull"
36
- end
37
- end
38
-
39
- after 'deploy', 'deploy:install'
40
- after 'deploy:new', 'deploy:install'
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,41 +0,0 @@
1
- module SiteLogic
2
-
3
- module Base
4
-
5
- @@sluggable_attribute = nil
6
-
7
- module ClassMethods
8
- def has_slug(attr)
9
- self.send(:set_callback, :save, :before, Proc.new{|doc| doc.make_slug})
10
- end
11
- end
12
-
13
- def self.included(base)
14
- base.extend(ClassMethods)
15
- end
16
-
17
- def make_slug
18
- if self.desired_slug && ! self.desired_slug.blank?
19
- text = self.desired_slug
20
- elsif self.slug
21
- text = self.slug
22
- elsif self.respond_to?(:page_title)
23
- text = self.page_title.to_s.downcase
24
- elsif self.respond_to?(:name)
25
- text = self.name.to_s.downcase
26
- end
27
-
28
- # Translation borrowed from permalink_fu
29
- text = text.to_s
30
- text.gsub!(/[^\x00-\x7F]+/, '-') # Remove anything non-ASCII entirely (e.g. diacritics).
31
- text.gsub!(/[^\/\w_ \-]+/i, '-') # Remove unwanted chars.
32
- text.gsub!(/[ \-]+/i, '-') # No more than one of the separator in a row.
33
- text.gsub!(/^\-|\-$/i, '') # Remove leading/trailing separator.
34
- text.downcase!
35
- self.slug = text
36
-
37
- end
38
-
39
- end
40
-
41
- end
@@ -1,7 +0,0 @@
1
- require 'site_logic'
2
- require 'rails'
3
-
4
- module SiteLogic
5
- class Engine < Rails::Engine
6
- end
7
- end
data/public/404.html DELETED
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
data/public/422.html DELETED
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
data/public/500.html DELETED
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,31 +0,0 @@
1
- Obfuscator = {
2
-
3
- extractUrl: function(url) {
4
- pattern = /#(.+)$/
5
- if (url.match(pattern)) {
6
- return "/" + RegExp.$1.replace(/%23/g,'/');
7
- }
8
- },
9
-
10
- decode: function(elem){
11
-
12
- var text = Obfuscator.extractUrl(elem.href);
13
- var dst = '';
14
- var len = text.length;
15
-
16
- if (text.length > 0) {
17
- for(var i=0; i < text.length ; i++) {
18
- b = text.charCodeAt(i)
19
- if( ( (b>64) && (b<78) ) || ( (b>96) && (b<110) ) ) {
20
- b=b+13;
21
- } else {
22
- if( ( (b>77) && (b<91) ) || ( (b>109) && (b<123) ) ) { b=b-13; }
23
- }
24
- t=String.fromCharCode(b);
25
- dst=dst.concat(t);
26
- }
27
- }
28
- elem.href = dst;
29
- }
30
- }
31
-
data/public/robots.txt DELETED
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /