canyon 0.0.1 → 0.0.2

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: 36a8f1d8684684e4323ac062af0294d15e24153a
4
- data.tar.gz: 675bdcb88f2151e34d525e5f0913a9978128ed11
3
+ metadata.gz: e704d24cc230eb034c517bdecfdcc276298b892f
4
+ data.tar.gz: 5c39a46842f7b9e02d1306de1a3812b49925e888
5
5
  SHA512:
6
- metadata.gz: c5b2473b776ae3965fa0ffb8f4f975971c331ba861d186da32aa7f51c3b1beedc186d64928f2239f00786cc7091c1b38ba367a057a341cb32e1c300fd4e4bdfe
7
- data.tar.gz: 9ab5818e3dfe53e2aaf40c2d64e4a6f52d3f7da321d2f8db9d3c382432973ec689ef258cf280d6e44c1630a01c6ae356eeec0410378e67265b16724c77dfcb3e
6
+ metadata.gz: 0a95c043ea2fa4fa647bfdb05661772cfe4e2059054ad0fdd125e81916059f26e40c722c85c7c616428aa9a0c3d9902f03e400523feac815f0f3c3cd3b27690f
7
+ data.tar.gz: f0ffcc5fcb02f8655a262c6e32d41c8761e20a6faa91fdbd04bee407afd0f581b8423e302b196923449b450ce7d1957320e6c6774bf5323363b6da6bccbd3ce9
@@ -1,20 +1,21 @@
1
+ The MIT License (MIT)
2
+
1
3
  Copyright (c) 2015 Martin Jagusch
2
4
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
10
11
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
13
14
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,18 +1,24 @@
1
1
  # Canyon
2
2
 
3
- Canyon is a Rails blogging engine, including only the backend. How you present the blog posts is up to you.
3
+ Canyon is a Rails blogging engine, it is build to get included in another Rails application. Read more about how Rails engines work [here](http://guides.rubyonrails.org/engines.html). It includes the admin section to create and update blog posts and to manage authors. How you use and present the blog posts is up to your main Rails application.
4
+
5
+ You can add Canyon to a new Rails application or an existing one.
4
6
 
5
7
  ### Installation
6
8
 
7
- Include the engine to your projects Gemfile. `Gemfile`
9
+ Include the engine to your projects Gemfile.
10
+
11
+ ``` ruby
12
+ # Gemfile
8
13
 
9
- ```
10
14
  gem 'canyon'
11
15
  ```
12
16
 
13
- Include the routes from the engine to your applications routing file. `config/routes.rb`
17
+ Include the routes from the engine to your applications routing file. What path you use for the admin section is up to you. In this example it is: `cy-admin`
14
18
 
15
19
  ``` ruby
20
+ # config/routes.rb
21
+
16
22
  Rails.application.routes.draw do
17
23
  # All your application routes.
18
24
 
@@ -20,10 +26,34 @@ Rails.application.routes.draw do
20
26
  end
21
27
  ```
22
28
 
23
- Load the engine sample data. `db/seeds.rb` (optional)
29
+ Load the engine sample data. (optional)
30
+
31
+ ``` ruby
32
+ # db/seeds.rb
24
33
 
25
- ```
26
34
  Canyon::Engine.load_seed
27
35
  ```
28
36
 
29
- Running `rake db:seed` will now include a default user and blog post.
37
+ Running `rake db:seed` will now include a default user and blog post from the engines seed file.
38
+
39
+ ## Configure
40
+
41
+ You can override any of the following defaults.
42
+
43
+ ``` ruby
44
+ # config/initializers/canyon.rb
45
+
46
+ Canyon.configure do |config|
47
+ config.display_summary_field = false
48
+ config.display_language_field = false
49
+ end
50
+ ```
51
+
52
+ ## Usage
53
+
54
+ To access published posts, use the following code in your e.g. controllers.
55
+
56
+ ``` ruby
57
+ Canyon::Post.published
58
+ # => ActiveRecord::Relation object to access published posts.
59
+ ```
@@ -45,12 +45,14 @@
45
45
  </div>
46
46
 
47
47
  <div class="row">
48
- <div class="col-md-6">
49
- <div class="form-group">
50
- <%= f.label :language %>
51
- <%= f.select :language, Canyon::Post::LANGUAGES, {}, class: 'form-control' %>
48
+ <% if Canyon.configuration.display_language_field %>
49
+ <div class="col-md-6">
50
+ <div class="form-group">
51
+ <%= f.label :language %>
52
+ <%= f.select :language, Canyon::Post::LANGUAGES, {}, class: 'form-control' %>
53
+ </div>
52
54
  </div>
53
- </div>
55
+ <% end %>
54
56
 
55
57
  <div class="col-md-6">
56
58
  <div class="form-group">
@@ -82,10 +84,12 @@
82
84
  </div>
83
85
  </div>
84
86
 
85
- <div class="form-group">
86
- <%= f.label :summary %>
87
- <%= f.text_area :summary, rows: 3, class: 'form-control post-summary', placeholder: 'A short summary for the homepage.' %>
88
- </div>
87
+ <% if Canyon.configuration.display_summary_field %>
88
+ <div class="form-group">
89
+ <%= f.label :summary %>
90
+ <%= f.text_area :summary, rows: 3, class: 'form-control post-summary', placeholder: 'A short summary for the homepage.' %>
91
+ </div>
92
+ <% end %>
89
93
 
90
94
  <div class="form-group">
91
95
  <%= f.label :content %>
@@ -19,13 +19,12 @@
19
19
  <span class="icon-bar"></span>
20
20
  <span class="icon-bar"></span>
21
21
  </button>
22
+
22
23
  <%= link_to 'Canyon', posts_path, class: 'navbar-brand' %>
23
24
  </div>
24
25
  <div id="navbar" class="collapse navbar-collapse">
25
26
  <ul class="nav navbar-nav">
26
27
  <li class="active"><%= link_to 'Posts', posts_path %></li>
27
- <li><%= link_to 'Categories', '#' %></li>
28
- <li><%= link_to 'Authors', '#' %></li>
29
28
  <li>
30
29
  <%= link_to request.base_url, target: '_blank' do %>
31
30
  <%= request.base_url %>
@@ -38,12 +37,13 @@
38
37
  </nav>
39
38
 
40
39
  <div class="container">
41
- <% flash.each do |name, flash_message| %>
40
+ <% flash.each do |name, message| %>
42
41
  <div class="alert alert-<%= name %> alert-dismissible" role="alert">
43
42
  <button type="button" class="close" data-dismiss="alert" aria-label="Close">
44
43
  <span aria-hidden="true">&times;</span>
45
44
  </button>
46
- <p><%= raw flash_message %></p>
45
+
46
+ <p><%= raw message %></p>
47
47
  </div>
48
48
  <% end %>
49
49
 
@@ -2,7 +2,7 @@ class CreateAuthors < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :canyon_authors do |t|
4
4
  t.string :name, null: false
5
- t.string :slug, null: false
5
+ t.string :login, null: false
6
6
  t.timestamps null: false
7
7
  end
8
8
  end
@@ -2,10 +2,10 @@ class CreatePosts < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :canyon_posts do |t|
4
4
  t.string :title, null: false
5
- t.string :slug, null: false
6
- t.string :language, null: false
5
+ t.string :slug
6
+ t.string :language
7
7
  t.text :summary
8
- t.text :content, null: false
8
+ t.text :content
9
9
  t.integer :parent_id
10
10
  t.integer :author_id, null: false
11
11
  t.boolean :deleted, null: false, default: false
@@ -1,15 +1,22 @@
1
- Canyon::Author.delete_all
2
- Canyon::Post.delete_all
3
-
4
- author = Canyon::Author.create(name: 'Guybrush Threepwood', slug: 'guybrush')
5
- Canyon::Author.create(name: 'Elaine Marley', slug: 'elaine')
1
+ guybrush = Canyon::Author.create(name: 'Guybrush Threepwood', login: 'guybrush')
2
+ elaine = Canyon::Author.create(name: 'Elaine Marley', login: 'elaine')
6
3
 
7
4
  Canyon::Post.create!(
8
- author: author,
5
+ author: guybrush,
9
6
  language: 'en',
10
7
  title: 'Markdown Syntax Example',
11
8
  slug: 'markdown-syntax-example',
12
- summary: 'This is our fist summary.',
13
- content: 'This is our **fist posts**.',
14
- published_at: Time.now,
9
+ summary: 'This is the fist summary.',
10
+ content: 'This is the **fist post**.',
11
+ published_at: 1.month.ago,
12
+ )
13
+
14
+ Canyon::Post.create!(
15
+ author: elaine,
16
+ language: 'en',
17
+ title: 'Second Example',
18
+ slug: 'Second-example',
19
+ summary: 'This is the second summary.',
20
+ content: 'This is the **second post**.',
21
+ published_at: 1.day.ago,
15
22
  )
@@ -1,3 +1,4 @@
1
+ require 'canyon/configuration'
1
2
  require 'canyon/engine'
2
3
 
3
4
  module Canyon
@@ -0,0 +1,18 @@
1
+ module Canyon
2
+ class Configuration
3
+ attr_accessor :display_summary_field, :display_language_field
4
+
5
+ def initialize
6
+ @display_summary_field = false
7
+ @display_language_field = false
8
+ end
9
+ end
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.configure
16
+ yield configuration
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Canyon
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canyon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Jagusch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-01 00:00:00.000000000 Z
11
+ date: 2015-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -109,6 +109,7 @@ files:
109
109
  - db/migrate/20150416053518_create_posts.rb
110
110
  - db/seeds.rb
111
111
  - lib/canyon.rb
112
+ - lib/canyon/configuration.rb
112
113
  - lib/canyon/engine.rb
113
114
  - lib/canyon/version.rb
114
115
  - lib/tasks/canyon_tasks.rake