canyon 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +17 -16
- data/README.md +37 -7
- data/app/views/canyon/posts/_form.html.erb +13 -9
- data/app/views/layouts/canyon/application.html.erb +4 -4
- data/db/migrate/20150416053508_create_authors.rb +1 -1
- data/db/migrate/20150416053518_create_posts.rb +3 -3
- data/db/seeds.rb +16 -9
- data/lib/canyon.rb +1 -0
- data/lib/canyon/configuration.rb +18 -0
- data/lib/canyon/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e704d24cc230eb034c517bdecfdcc276298b892f
|
4
|
+
data.tar.gz: 5c39a46842f7b9e02d1306de1a3812b49925e888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a95c043ea2fa4fa647bfdb05661772cfe4e2059054ad0fdd125e81916059f26e40c722c85c7c616428aa9a0c3d9902f03e400523feac815f0f3c3cd3b27690f
|
7
|
+
data.tar.gz: f0ffcc5fcb02f8655a262c6e32d41c8761e20a6faa91fdbd04bee407afd0f581b8423e302b196923449b450ce7d1957320e6c6774bf5323363b6da6bccbd3ce9
|
data/LICENSE.txt
CHANGED
@@ -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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
-
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
OF
|
20
|
-
|
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,
|
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.
|
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.
|
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.
|
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
|
-
|
49
|
-
<div class="
|
50
|
-
|
51
|
-
|
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
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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,
|
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">×</span>
|
45
44
|
</button>
|
46
|
-
|
45
|
+
|
46
|
+
<p><%= raw message %></p>
|
47
47
|
</div>
|
48
48
|
<% end %>
|
49
49
|
|
@@ -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
|
6
|
-
t.string :language
|
5
|
+
t.string :slug
|
6
|
+
t.string :language
|
7
7
|
t.text :summary
|
8
|
-
t.text :content
|
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
|
data/db/seeds.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
|
-
Canyon::Author.
|
2
|
-
Canyon::
|
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:
|
5
|
+
author: guybrush,
|
9
6
|
language: 'en',
|
10
7
|
title: 'Markdown Syntax Example',
|
11
8
|
slug: 'markdown-syntax-example',
|
12
|
-
summary: 'This is
|
13
|
-
content: 'This is
|
14
|
-
published_at:
|
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
|
)
|
data/lib/canyon.rb
CHANGED
@@ -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
|
data/lib/canyon/version.rb
CHANGED
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.
|
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-
|
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
|