slices 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e7962d1eb6d07caf9cf1aad9126223a9c191247
4
- data.tar.gz: d37d49e3079bd5d224218accb94cbcd0c1c732ad
3
+ metadata.gz: 8f4968b6bc81c708989828fcbc0eb40ec6675c82
4
+ data.tar.gz: 0d8ff3c4a2bd832371719d01cd949eb66f20f2ce
5
5
  SHA512:
6
- metadata.gz: cfb0c45a213c460c2c177d920fd5d20f7a09efd741b76e9c93d1f66553edaec50af3129f1c693e400b496a4e599887baa986f34e4c83554bd87c29ae6e4a0d4c
7
- data.tar.gz: e4d5fc2155751c47264b16c7573b41ddcaa5b892ed9a943e6e9108facd1e644fb68be1d6347563c4a63eedf92852bb84dbe9106755448123ea28cdb85ede93e8
6
+ metadata.gz: 1cad25d7585e79096c3751e1a75f0aa143810288541ce2856254d648c3a1f759a075c8fa224c5ea60c5f512e21b15951a870498061f1ecad8561c87afd790dde
7
+ data.tar.gz: cc79cd57e8a0998b978ca0ea22ea9c5a66ba8d62ec34c913325f43981fad32ecca9db6df366e877aff6ea45db650a2b4c87cb840130725b9cc04951c13275934
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.0.3 / 2014-03-12
2
+
3
+ * Put Page#as_json into its own module so it can be overridden in other modules
4
+ * Add rails generate slices:install command
5
+ * Upgrade Devise to 2.2.8
6
+
1
7
  # 1.0.2 / 2014-01-13
2
8
 
3
9
  * Fix (more) gem package issue
data/README.md CHANGED
@@ -1,37 +1,26 @@
1
1
  # Slices CMS
2
2
 
3
- In-house CMS of [With Associates](http://withassociates.com/)
3
+ In-house CMS of [With Associates](http://withassociates.com/).
4
4
 
5
5
  ## Starting a new Slices project
6
6
 
7
7
  Slices requires Ruby, MongoDB and ImageMagick. If you don't have them installed, follow this [guide](https://github.com/withassociates/slices/wiki/Installation.md) before beginning.
8
8
 
9
- We'll need to checkout the Slices project, install the relevant gems using Bundler and use a Rails template to create the new project:
10
-
11
- $ cd ~/Projects # or wherever you store git repositories
12
- $ git clone git@github.com:withassociates/slices.git
13
- $ cd slices
14
- $ gem install bundler
15
- $ bundle install
16
-
17
- Or if you have Slices already installed:
18
-
19
- $ cd ~/Projects/slices # or wherever you store git repositories
20
- $ git pull
21
- $ bundle install
22
-
23
9
  Now we're ready to create the Slices project:
24
10
 
25
11
  $ cd ~/Projects
26
- $ gem install rails -v '~> 3.2.0'
27
- $ rails new mywebsite -JOT -m ~/Projects/slices/lib/generators/templates/slices.rb
12
+ $ rails _3.2.16_ new mywebsite -O
13
+ $ cd ~/Projects/mywebsite
28
14
 
29
- At the end of this process we should have a new Slices project with a git repository created, gems installed, database seeded and ready to run:
15
+ Add 'slices' to the Gemfile of your new project:
30
16
 
31
- $ cd ~/Projects/mywebsite
32
- $ foreman start
17
+ gem 'slices'
18
+
19
+ Run `rails generate slices:install` in the terminal and follow the instructions.
20
+
21
+ If you intend to deploy your Slices app to Heroku, run `rails generate slices:install --heroku` to make life easier.
33
22
 
34
- Visit http://localhost:5000/admin to begin using Slices.
23
+ You're ready to go! Run `rails server` and visit http://localhost:3000/admin to begin using Slices.
35
24
 
36
25
  The next step is to create some [slices](https://github.com/withassociates/slices/wiki/Creating-Slices) - there are more guides in the [Wiki](https://github.com/withassociates/slices/wiki).
37
26
 
@@ -3,8 +3,8 @@ class Admin::Auth::OmniauthCallbacksController < ::Devise::OmniauthCallbacksCont
3
3
  helper 'admin/admin'
4
4
 
5
5
  def google_apps
6
- domain = Slices::Config.google_apps_domain
7
- @admin = Admin.find_for_domain(domain)
6
+ email = request.env['omniauth.auth']['info']['email']
7
+ @admin = Admin.find_for_google_apps(email)
8
8
 
9
9
  if @admin.persisted?
10
10
  sign_in_and_redirect @admin, event: :authentication
data/app/models/admin.rb CHANGED
@@ -3,20 +3,38 @@ class Admin
3
3
  include MongoSearch::Searchable
4
4
 
5
5
  field :name
6
- field :super_user, type: Boolean, :default => false
6
+ field :super_user, type: Boolean, default: false
7
+
8
+ ## Database authenticatable
9
+ field :email, type: String
10
+ field :encrypted_password, type: String
11
+
12
+ ## Recoverable
13
+ field :reset_password_token, type: String
14
+ field :reset_password_sent_at, type: Time
15
+
16
+ ## Rememberable
17
+ field :remember_created_at, type: Time
18
+
19
+ ## Trackable
20
+ field :sign_in_count, type: Integer
21
+ field :current_sign_in_at, type: Time
22
+ field :last_sign_in_at, type: Time
23
+ field :current_sign_in_ip, type: String
24
+ field :last_sign_in_ip, type: String
7
25
 
8
26
  text_search_in :name, :email
9
27
 
10
28
  validates_uniqueness_of :email, case_sensitive: false, scope: :site_id
11
-
12
29
  validates_presence_of :email
13
- attr_accessible :email, :password, :password_confirmation, :name
30
+ validates_presence_of :encrypted_password
14
31
 
15
32
  devise :database_authenticatable, :recoverable, :rememberable,
16
- :trackable, :validatable, :omniauthable
33
+ :trackable, :validatable
34
+ devise :omniauthable, omniauth_providers: [:google_apps]
17
35
 
18
- def self.find_for_domain(domain)
19
- where(email: /@#{domain}$/).first
36
+ def self.find_for_google_apps(email)
37
+ where(email: email).first || where(email: /@#{Slices::Config.google_apps_domain}$/).first
20
38
  end
21
39
 
22
40
  def super?
data/app/models/page.rb CHANGED
@@ -4,6 +4,7 @@ class Page
4
4
  include MongoSearch::Searchable
5
5
 
6
6
  include Slices::Tree
7
+ include Slices::PageAsJSON
7
8
  include Slices::HasSlices
8
9
  include Slices::HasAttachments::PageInstanceMethods
9
10
 
@@ -146,19 +147,6 @@ class Page
146
147
  end
147
148
  end
148
149
 
149
- def as_json(options = {})
150
- options ||= {}
151
-
152
- hash = attributes.symbolize_keys.except(:_id, :_type, :_keywords, :set_slices, :site_id).merge(
153
- id: id,
154
- permalink: permalink,
155
- slices: ordered_slices_for(options[:slice_embed]).map {|slice| slice.as_json },
156
- available_layouts: available_layouts
157
- )
158
-
159
- keys = options[:only]
160
- keys ? hash.slice(keys) : hash
161
- end
162
150
 
163
151
  # Added in merge or page & content
164
152
  def set_keywords
@@ -25,11 +25,13 @@
25
25
 
26
26
  </div>
27
27
 
28
- <% content_for :js_head do %>
29
- $(document).bind("keydown", function(e) {
30
- if(e.keyCode == 187) {
31
- window.location = "<%= admin_omniauth_authorize_path(:google_apps) %>";
32
- }
33
- });
28
+ <% if Slices::Config.google_apps_domain %>
29
+ <% content_for :js_head do %>
30
+ $(document).bind("keydown", function(e) {
31
+ if(e.keyCode == 187) {
32
+ window.location = "<%= admin_omniauth_authorize_path(:google_apps) %>";
33
+ }
34
+ });
35
+ <% end %>
34
36
  <% end %>
35
37
 
@@ -1,14 +1,11 @@
1
- require 'omniauth/openid'
2
- require 'openid/store/filesystem'
3
1
  require 'devise/orm/mongoid'
2
+ require 'omniauth-google-apps'
4
3
 
5
4
  ActiveSupport::SecureRandom = SecureRandom
6
5
 
7
6
  Devise.setup do |config|
8
- config.omniauth :google_apps,
9
- OpenID::Store::Filesystem.new('/tmp'),
10
- domain: Slices::Config.google_apps_domain
11
-
12
- config.use_salt_as_remember_token = true
13
7
  config.mailer_sender = "hello@example.com"
8
+ if Slices::Config.google_apps_domain
9
+ config.omniauth :google_apps, domain: Slices::Config.google_apps_domain
10
+ end
14
11
  end
data/config/routes.rb CHANGED
@@ -7,9 +7,9 @@ end
7
7
  Rails.application.routes.draw do
8
8
 
9
9
  devise_for :admin, :path => "admin", :controllers => {
10
- :omniauth_callbacks => "admin/auth/omniauth_callbacks",
11
10
  :passwords => "admin/auth/passwords",
12
11
  :sessions => "admin/auth/sessions",
12
+ :omniauth_callbacks => "admin/auth/omniauth_callbacks",
13
13
  }
14
14
 
15
15
  namespace :admin do
@@ -0,0 +1,18 @@
1
+ Description:
2
+ Installs Slices into your Rails 3.2 app.
3
+
4
+ Example:
5
+ rails generate slices:install
6
+
7
+ This command will:
8
+ Create app/slices
9
+ Create a Slices initializer
10
+ Create an empty application layout
11
+
12
+ Options:
13
+ [--mongoid] # Add config/mongoid.yml
14
+ # Default: false
15
+
16
+ Tips:
17
+ Note the shorthand version `rails g slices:install`
18
+
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rails/generators'
4
+ require 'thor'
5
+
6
+ module Slices
7
+ class InstallGenerator < ::Rails::Generators::Base
8
+ source_root File.expand_path('../templates', __FILE__)
9
+ class_option :heroku, type: :boolean, default: false, desc: "Configure Slices for easy Heroku deployment."
10
+ include Thor::Actions
11
+
12
+ desc "This generator installs Slices within a Rails app."
13
+
14
+ def create_slices_dir
15
+ say "Running the Slices installer..."
16
+ create_file "app/slices/.gitkeep"
17
+ end
18
+
19
+ def create_initializer
20
+ copy_file "slices.rb", "config/initializers/slices.rb"
21
+ end
22
+
23
+ def create_application_layout
24
+ copy_file "application.html.erb", "app/views/layouts/default.html.erb"
25
+ end
26
+
27
+ def optionally_create_mongoid_yaml
28
+ copy_file "mongoid.yml", "config/mongoid.yml"
29
+ end
30
+
31
+ def delete_superfluous_files
32
+ remove_file "public/index.html"
33
+ remove_file "public/rails.png"
34
+ remove_dir "public/assets"
35
+ end
36
+
37
+ def heroku_options
38
+ if options.heroku?
39
+ say "Installing Slices for Heroku", :green
40
+ inject_into_file "#{Rails.root}/config/application.rb", "config.assets.initialize_on_precompile = false",
41
+ :after => "config.assets.enabled = true\n"
42
+
43
+ gsub_file "#{Rails.root}/config/environments/production.rb",
44
+ "config.assets.compile = false",
45
+ "config.assets.compile = true"
46
+ end
47
+ end
48
+
49
+ def finishing_up
50
+ say ""
51
+ say "---------------------------", :green
52
+ say "All done!", :green
53
+ say "---------------------------", :green
54
+ say ""
55
+ say "Next, run 'rake slices:seed' to create your Slices admin user and home page."
56
+ say "Then you can run 'rails server' and visit http://localhost:3000/admin to begin using Slices."
57
+ say "The next step is to create some slices. You can find the guides in the wiki:"
58
+ say "https://github.com/withassociates/slices/wiki"
59
+ say ""
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,18 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title><%= @page.title %></title>
5
+ <meta name="description" content="<%= @page.meta_description %>">
6
+ <%= stylesheet_link_tag *%w[
7
+ application
8
+ ] %>
9
+ <%= javascript_include_tag *%w[
10
+ application
11
+ ] %>
12
+ </head>
13
+ <body class="layout-default">
14
+ <section id="main" role="main">
15
+ <%= container "content" %>
16
+ </section>
17
+ </body>
18
+ </html>
@@ -0,0 +1,12 @@
1
+ development:
2
+ host: localhost
3
+ database: myapp_development
4
+
5
+ test:
6
+ host: localhost
7
+ database: myapp_test
8
+
9
+ production:
10
+ host: localhost
11
+ database: myapp_development
12
+
@@ -0,0 +1,11 @@
1
+ # Slices::Config.add_asset_styles(
2
+ # slice_full_width: '945x496>',
3
+ # avatar: '30x30#',
4
+ # )
5
+
6
+ # Configure the Google Apps domain to use for quick auth.
7
+ # Press the '=' key on the admin sign-in screen to authenticate via
8
+ # a Google Apps account within the domain configured here.
9
+ # Slices::Config.google_apps_domain = 'example.com'
10
+
11
+ ActionView::Base.send(:include, AssetsHelper)
data/lib/slices.rb CHANGED
@@ -22,6 +22,7 @@ module Slices
22
22
  autoload :GeneratorMacros, 'slices/generator_macros'
23
23
  autoload :HasSlices, 'slices/has_slices'
24
24
  autoload :HasAttachments, 'slices/has_attachments'
25
+ autoload :PageAsJSON, 'slices/page_as_json'
25
26
  autoload :Renderer, 'slices/renderer'
26
27
  autoload :PositionHelper, 'slices/position_helper'
27
28
  autoload :SplitDateTimeField, 'slices/split_date_time_field'
@@ -55,9 +56,8 @@ require 'slices/will_paginate_mongoid'
55
56
  require 'slices/will_paginate'
56
57
  require 'set_link_renderer'
57
58
 
58
- if Rails.env.development?
59
- Slices::Config.use_snippets!
60
- end
59
+ Slices::Config.use_snippets!
60
+
61
61
  if Rails.env.test? || Rails.env.development?
62
62
  require 'standard_tree'
63
63
  end
@@ -0,0 +1,18 @@
1
+ module Slices
2
+ # We keep this method in here to facilate easier overriding when re-opening Page.
3
+ module PageAsJSON
4
+ def as_json(options = {})
5
+ options ||= {}
6
+
7
+ hash = attributes.symbolize_keys.except(:_id, :_type, :_keywords, :set_slices, :site_id).merge(
8
+ id: id,
9
+ permalink: permalink,
10
+ slices: ordered_slices_for(options[:slice_embed]).map {|slice| slice.as_json },
11
+ available_layouts: available_layouts
12
+ )
13
+
14
+ keys = options[:only]
15
+ keys ? hash.slice(keys) : hash
16
+ end
17
+ end
18
+ end
@@ -1,4 +1,4 @@
1
1
  module Slices
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slices
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - With Associates
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-13 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson_ext
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.3.4
47
+ version: 2.2.8
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.3.4
54
+ version: 2.2.8
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: highline
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -109,19 +109,19 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.0.8
111
111
  - !ruby/object:Gem::Dependency
112
- name: oa-openid
112
+ name: omniauth-google-apps
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.3.2
117
+ version: 0.1.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.3.2
124
+ version: 0.1.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: paperclip
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +198,14 @@ dependencies:
198
198
  requirements:
199
199
  - - '='
200
200
  - !ruby/object:Gem::Version
201
- version: 3.0.pre2
201
+ version: 3.0.pre4
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
206
  - - '='
207
207
  - !ruby/object:Gem::Version
208
- version: 3.0.pre2
208
+ version: 3.0.pre4
209
209
  description: A Rails 3 CMS that can be embedded within your own site.
210
210
  email:
211
211
  - hello@withassociates.com
@@ -378,7 +378,6 @@ files:
378
378
  - app/views/layouts/admin.html.erb
379
379
  - config/initializers/backtrace_silencers.rb
380
380
  - config/initializers/devise.rb
381
- - config/initializers/formtastic.rb
382
381
  - config/initializers/inflections.rb
383
382
  - config/initializers/mime_types.rb
384
383
  - config/initializers/secret_token.rb
@@ -401,6 +400,11 @@ files:
401
400
  - lib/generators/slice/templates/show_slice.rb
402
401
  - lib/generators/slice/templates/slice.rb
403
402
  - lib/generators/slice/templates/slice_fields.hbs
403
+ - lib/generators/slices/USAGE
404
+ - lib/generators/slices/install_generator.rb
405
+ - lib/generators/slices/templates/application.html.erb
406
+ - lib/generators/slices/templates/mongoid.yml
407
+ - lib/generators/slices/templates/slices.rb
404
408
  - lib/generators/templates/slices.rb
405
409
  - lib/mongo_search.rb
406
410
  - lib/paperclip_validator.rb
@@ -420,6 +424,7 @@ files:
420
424
  - lib/slices/i18n.rb
421
425
  - lib/slices/i18n/backend.rb
422
426
  - lib/slices/i18n_backend.rb
427
+ - lib/slices/page_as_json.rb
423
428
  - lib/slices/paperclip.rb
424
429
  - lib/slices/position_helper.rb
425
430
  - lib/slices/renderer.rb
@@ -441,7 +446,7 @@ files:
441
446
  - public/slices/templates/set_page_entry_content_main.hbs
442
447
  - public/slices/templates/set_page_entry_content_meta.hbs
443
448
  - public/slices/templates/slice.hbs
444
- homepage: http://www.withassociates.com
449
+ homepage: http://slices.withassociates.com
445
450
  licenses:
446
451
  - MIT
447
452
  metadata: {}
@@ -461,7 +466,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
461
466
  version: 1.3.6
462
467
  requirements: []
463
468
  rubyforge_project: slices
464
- rubygems_version: 2.2.0.rc.1
469
+ rubygems_version: 2.2.2
465
470
  signing_key:
466
471
  specification_version: 4
467
472
  summary: Slices CMS, from With Associates
@@ -1,55 +0,0 @@
1
- # Set the default text field size when input is a string. Default is 50.
2
- # Formtastic::SemanticFormBuilder.default_text_field_size = 50
3
-
4
- # Set the default text area height when input is a text. Default is 20.
5
- # Formtastic::SemanticFormBuilder.default_text_area_height = 5
6
-
7
- # Should all fields be considered "required" by default?
8
- # Rails 2 only, ignored by Rails 3 because it will never fall back to this default.
9
- # Defaults to true.
10
- # Formtastic::SemanticFormBuilder.all_fields_required_by_default = true
11
-
12
- # Should select fields have a blank option/prompt by default?
13
- # Defaults to true.
14
- # Formtastic::SemanticFormBuilder.include_blank_for_select_by_default = true
15
-
16
- # Set the string that will be appended to the labels/fieldsets which are required
17
- # It accepts string or procs and the default is a localized version of
18
- # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
19
- # in your locale, it will replace the abbr title properly. But if you don't want to use
20
- # abbr tag, you can simply give a string as below
21
- # Formtastic::SemanticFormBuilder.required_string = "(required)"
22
-
23
- # Set the string that will be appended to the labels/fieldsets which are optional
24
- # Defaults to an empty string ("") and also accepts procs (see required_string above)
25
- # Formtastic::SemanticFormBuilder.optional_string = "(optional)"
26
-
27
- # Set the way inline errors will be displayed.
28
- # Defaults to :sentence, valid options are :sentence, :list and :none
29
- # Formtastic::SemanticFormBuilder.inline_errors = :sentence
30
-
31
- # Set the method to call on label text to transform or format it for human-friendly
32
- # reading when formtastic is used without object. Defaults to :humanize.
33
- # Formtastic::SemanticFormBuilder.label_str_method = :humanize
34
-
35
- # Set the array of methods to try calling on parent objects in :select and :radio inputs
36
- # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
37
- # that is found on the object will be used.
38
- # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
39
- # Formtastic::SemanticFormBuilder.collection_label_methods = [
40
- # "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
41
-
42
- # Formtastic by default renders inside li tags the input, hints and then
43
- # errors messages. Sometimes you want the hints to be rendered first than
44
- # the input, in the following order: hints, input and errors. You can
45
- # customize it doing just as below:
46
- # Formtastic::SemanticFormBuilder.inline_order = [:input, :hints, :errors]
47
-
48
- # Specifies if labels/hints for input fields automatically be looked up using I18n.
49
- # Default value: false. Overridden for specific fields by setting value to true,
50
- # i.e. :label => true, or :hint => true (or opposite depending on initialized value)
51
- # Formtastic::SemanticFormBuilder.i18n_lookups_by_default = false
52
-
53
- # You can add custom inputs or override parts of Formtastic by subclassing SemanticFormBuilder and
54
- # specifying that class here. Defaults to SemanticFormBuilder.
55
- # Formtastic::SemanticFormHelper.builder = MyCustomBuilder