spud_core 0.8.18 → 0.8.19

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -59,4 +59,5 @@ Spud uses RSpec for testing. Get the tests running with a few short commands:
59
59
  After the tests have completed the current code coverage stats is available by opening ```/coverage/index.html``` in a browser.
60
60
 
61
61
 
62
+ NOTE: Spud Core is Retina Resolution Compatible Now
62
63
 
@@ -1,12 +1,11 @@
1
1
  class Spud::ApplicationController < ActionController::Base
2
2
  unloadable
3
3
  protect_from_forgery
4
- helper_method :current_user_session, :current_user, :current_site_name
4
+ helper_method :current_user_session, :current_user, :current_site_name, :current_site_id
5
5
  around_filter :set_time_zone
6
6
  around_filter :multisite_caching
7
7
  before_filter :to
8
8
 
9
-
10
9
  def current_site_name
11
10
  # puts "request.host_with_port = #{request.host_with_port}"
12
11
  return Spud::Core.site_name if !Spud::Core.multisite_mode_enabled
@@ -16,6 +15,11 @@ class Spud::ApplicationController < ActionController::Base
16
15
  return config[:site_name]
17
16
  end
18
17
 
18
+ def current_site_id
19
+ config = Spud::Core.site_config_for_host(request.host_with_port)
20
+ return config[:site_id] unless config.blank?
21
+ end
22
+
19
23
  private
20
24
 
21
25
  def to
@@ -1,14 +1,5 @@
1
1
  module Spud::Admin::ApplicationHelper
2
2
 
3
- def hidpi_asset(path)
4
- begin
5
- return nil if Rails.application.assets.find_asset(path.gsub(/\.png/,"@2x.png")).nil?
6
- asset_path = asset_path(path.gsub(/\.png/,"@2x.png"))
7
- return asset_path
8
- rescue
9
- return nil
10
- end
11
- end
12
3
  def timestamp(timedate=nil)
13
4
  return "Never" if timedate.blank?
14
5
  return Time.now() - timedate > 604800 ? timedate.strftime("%B %d") + ' at ' + timedate.strftime("%I:%M %p") : time_ago_in_words(timedate) + ' ago'
@@ -5,7 +5,7 @@
5
5
  </span>
6
6
  <h2>
7
7
  <%if @page_thumbnail%>
8
- <span class="thumb_wrapper"><%=image_tag(@page_thumbnail,:hidpi_src => hidpi_asset(@page_thumbnail))%></span>
8
+ <span class="thumb_wrapper"><%=image_tag(@page_thumbnail)%></span>
9
9
  <%end%>
10
10
  <%=@page_name%>
11
11
  </h2>
@@ -1,21 +1,36 @@
1
1
  module Spud
2
2
  module Core
3
3
  include ActiveSupport::Configurable
4
- config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address
4
+ config_accessor :site_name,:admin_applications,:sitemap_urls,:multisite_mode_enabled,:multisite_config,:from_address,:site_id,:short_name
5
5
  self.admin_applications = [{:name => "Users",:thumbnail => "spud/admin/users_thumb.png",:url => "/spud/admin/users",:order => 100}]
6
6
  self.site_name = "Company Name"
7
+ self.site_id = 0
8
+ self.short_name = 'default'
7
9
  self.sitemap_urls = []
8
10
  self.multisite_mode_enabled = false
9
11
  self.multisite_config = []
10
12
  self.from_address = "no-reply@spudengine.com"
13
+
11
14
  def self.site_config_for_host(host)
12
-
13
- configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
14
- if configs.blank?
15
- return nil
16
- else
17
- return configs[0]
18
- end
19
- end
15
+ configs = Spud::Core.multisite_config.select{|p| p[:hosts].include?(host)}
16
+ if configs.blank?
17
+ return default_site_config
18
+ else
19
+ return configs[0]
20
+ end
21
+ end
22
+
23
+ def self.site_config_for_id(id)
24
+ if(id == Spud::Core.config.site_id)
25
+ return self.default_site_config
26
+ else
27
+ matches = Spud::Core.config.multisite_config.select{ |site| site[:site_id] == id }
28
+ return matches[0] if matches.any?
29
+ end
30
+ end
31
+
32
+ def self.default_site_config
33
+ return {:site_id => Spud::Core.config.site_id, :site_name => Spud::Core.config.site_name, :short_name => Spud::Core.config.short_name}
34
+ end
20
35
  end
21
36
  end
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "0.8.18"
3
+ VERSION = "0.8.19"
4
4
  end
5
5
  end
@@ -2,21 +2,18 @@ require 'spec_helper'
2
2
 
3
3
  describe Spud::ApplicationController do
4
4
 
5
-
6
5
  before :each do
7
6
  activate_authlogic
8
7
  @user = FactoryGirl.create(:spud_user)
9
8
  @session = SpudUserSession.create(@user)
10
9
  end
11
10
 
12
-
13
-
14
- describe :current_site_name do
15
- controller(Spud::ApplicationController) do
16
- def index
17
- render :nothing => true
18
- end
11
+ describe :current_site_name do
12
+ controller(Spud::ApplicationController) do
13
+ def index
14
+ render :nothing => true
19
15
  end
16
+ end
20
17
  it "should return config site name if multisite is disabled" do
21
18
  Spud::Core.configure do |config|
22
19
  config.site_name = "Test Site"
@@ -36,14 +33,41 @@ describe Spud::ApplicationController do
36
33
  Spud::Core.configure do |config|
37
34
  config.site_name = "Test Site"
38
35
  config.multisite_mode_enabled = true
39
- config.multisite_config += [{:hosts => ["test.host"],:site_name =>"Site B"}]
36
+ config.multisite_config += [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
40
37
  end
41
38
 
42
39
  # puts request.host_with_port
43
40
  # helper.request = {:host_with_port => "example.com"}
44
41
  @controller.request = request
45
42
  @controller.current_site_name.should == 'Site B'
43
+ end
44
+ end
45
+
46
+ describe :current_site_id do
47
+
48
+ controller(Spud::ApplicationController) do
49
+ def index
50
+ render :nothing => true
51
+ end
46
52
  end
47
53
 
54
+ it "should return the default site id if multisite is disabled" do
55
+ Spud::Core.configure do |config|
56
+ config.site_id = 0
57
+ config.multisite_mode_enabled = false
58
+ config.multisite_config = []
59
+ end
60
+ @controller.current_site_id.should == 0
61
+ end
62
+
63
+ it "should return the current site id if multisite is enabled" do
64
+ Spud::Core.configure do |config|
65
+ config.multisite_mode_enabled = true
66
+ config.multisite_config = [{:hosts => ["test.host"], :site_name =>"Site B", :site_id => 1}]
67
+ end
68
+ @controller.request = request
69
+ @controller.current_site_id.should == 1
70
+ end
71
+
48
72
  end
49
73
  end
@@ -1,17 +1,39 @@
1
1
  Connecting to database specified by database.yml
2
-  (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
3
-  (22.6ms) DROP DATABASE IF EXISTS `spud_core_test`
2
+  (65.4ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
3
+  (144.1ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
4
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
5
+ Migrating to CreateSpudAdminPermissions (20111214161011)
6
+  (103.8ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
7
+  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20111214161011')
8
+ Migrating to CreateSpudUsers (20111214161146)
9
+  (113.1ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
10
+  (117.7ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
11
+  (111.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
12
+  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20111214161146')
13
+ Migrating to AddTimeZoneToSpudUser (20120327124229)
14
+  (149.1ms) ALTER TABLE `spud_users` ADD `time_zone` varchar(255)
15
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120327124229')
16
+ Migrating to AddScopeToSpudAdminPermissions (20120328235431)
17
+  (130.5ms) ALTER TABLE `spud_admin_permissions` ADD `scope` varchar(255)
18
+  (0.5ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120328235431')
19
+ Migrating to CreateSpudUserSettings (20120329174000)
20
+  (105.9ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
21
+  (0.8ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20120329174000')
22
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations`
23
+ Connecting to database specified by database.yml
24
+  (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` 
25
+  (0.5ms) DROP DATABASE IF EXISTS `spud_core_test`
4
26
   (0.3ms) CREATE DATABASE `spud_core_test` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`
5
-  (23.9ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `scope` varchar(255)) ENGINE=InnoDB
6
-  (20.2ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
7
-  (9.2ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `time_zone` varchar(255)) ENGINE=InnoDB
8
-  (13.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
9
-  (11.9ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
10
-  (10.6ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
11
-  (15.6ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
12
-  (0.1ms) SELECT version FROM `schema_migrations`
13
-  (1.3ms) INSERT INTO `schema_migrations` (version) VALUES ('20120329174000')
14
-  (0.2ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161011')
15
-  (0.7ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161146')
16
-  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120327124229')
17
-  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120328235431')
27
+  (54.2ms) CREATE TABLE `spud_admin_permissions` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `user_id` int(11), `name` varchar(255), `access` tinyint(1), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `scope` varchar(255)) ENGINE=InnoDB
28
+  (177.3ms) CREATE TABLE `spud_user_settings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `spud_user_id` int(11), `key` varchar(255), `value` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=InnoDB
29
+  (191.0ms) CREATE TABLE `spud_users` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `first_name` varchar(255), `last_name` varchar(255), `super_admin` tinyint(1), `login` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `crypted_password` varchar(255) NOT NULL, `password_salt` varchar(255) NOT NULL, `persistence_token` varchar(255) NOT NULL, `single_access_token` varchar(255) NOT NULL, `perishable_token` varchar(255) NOT NULL, `login_count` int(11) DEFAULT 0 NOT NULL, `failed_login_count` int(11) DEFAULT 0 NOT NULL, `last_request_at` datetime, `current_login_at` datetime, `last_login_at` datetime, `current_login_ip` varchar(255), `last_login_ip` varchar(255), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL, `time_zone` varchar(255)) ENGINE=InnoDB
30
+  (105.0ms) CREATE INDEX `index_spud_users_on_email` ON `spud_users` (`email`)
31
+  (100.1ms) CREATE INDEX `index_spud_users_on_login` ON `spud_users` (`login`)
32
+  (115.5ms) CREATE TABLE `schema_migrations` (`version` varchar(255) NOT NULL) ENGINE=InnoDB
33
+  (127.3ms) CREATE UNIQUE INDEX `unique_schema_migrations` ON `schema_migrations` (`version`)
34
+  (0.3ms) SELECT version FROM `schema_migrations`
35
+  (0.6ms) INSERT INTO `schema_migrations` (version) VALUES ('20120329174000')
36
+  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161011')
37
+  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20111214161146')
38
+  (0.4ms) INSERT INTO `schema_migrations` (version) VALUES ('20120327124229')
39
+  (0.3ms) INSERT INTO `schema_migrations` (version) VALUES ('20120328235431')