home_page_blog 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +26 -0
- data/app/assets/stylesheets/home_page_blog/posts.css +164 -0
- data/app/controllers/concerns/blog_controller.rb +20 -0
- data/app/controllers/home_controller.rb +3 -0
- data/app/controllers/posts_controller.rb +79 -0
- data/app/models/post.rb +35 -0
- data/app/views/layouts/home_page_blog/application.html.erb +53 -0
- data/app/views/posts/_form.html.erb +17 -0
- data/app/views/posts/_post.html.erb +24 -0
- data/app/views/posts/_sidebar.html.erb +4 -0
- data/app/views/posts/edit.html.erb +3 -0
- data/app/views/posts/index.html.erb +19 -0
- data/app/views/posts/index.txt +65 -0
- data/app/views/posts/new.html.erb +3 -0
- data/app/views/posts/show.html.erb +3 -0
- data/app/views/posts/sidebar/_about.html.erb +5 -0
- data/app/views/posts/sidebar/_social_links.html.erb +6 -0
- data/config/locales/general/en.yml +10 -0
- data/config/locales/resources/post/en.yml +30 -0
- data/config/locales/resources/post_archive/en.yml +4 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20150307194234_create_initial_blog_schema.rb +17 -0
- data/lib/home_page_blog.rb +8 -0
- data/lib/home_page_blog/engine.rb +13 -0
- data/lib/home_page_blog/navigation.rb +26 -0
- data/lib/home_page_blog/version.rb +3 -0
- data/lib/tasks/home_page_blog_tasks.rake +4 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 742885d131a2cb8a2a15c2af9824e5485f11310b
|
4
|
+
data.tar.gz: 9f6968552bb9635effdea6d0e0c5899c296041db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6c39fc829bdbfd47864e8f2228c297ed4b12b9fa2c196346f335fe03cfc753e0abcc6e3c8d6a70e1b488923c93d0e8fbc773d14fbeaa86a904e761d2ebd914b2
|
7
|
+
data.tar.gz: 3d9ca98d7626f67cecffb721511751c1a492cb89c21e712cac67f0ebf0ac3cecfc2e6ef17326e33d17166049cc4ec3f82cc37844d5f352ca99da609b9a9c7ba1
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Mathias Gawlista
|
2
|
+
|
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:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
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.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'HomePageBlog'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
@@ -0,0 +1,164 @@
|
|
1
|
+
/*
|
2
|
+
* Globals
|
3
|
+
*/
|
4
|
+
|
5
|
+
body {
|
6
|
+
color: #555;
|
7
|
+
}
|
8
|
+
|
9
|
+
h1, .h1,
|
10
|
+
h2, .h2,
|
11
|
+
h3, .h3,
|
12
|
+
h4, .h4,
|
13
|
+
h5, .h5,
|
14
|
+
h6, .h6 {
|
15
|
+
margin-top: 0;
|
16
|
+
font-weight: normal;
|
17
|
+
color: #333;
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
/*
|
22
|
+
* Override Bootstrap's default container.
|
23
|
+
*/
|
24
|
+
|
25
|
+
@media (min-width: 1200px) {
|
26
|
+
.container {
|
27
|
+
width: 970px;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
/*
|
33
|
+
* Masthead for nav
|
34
|
+
*/
|
35
|
+
|
36
|
+
.blog-masthead {
|
37
|
+
background-color: #428bca;
|
38
|
+
-webkit-box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
|
39
|
+
box-shadow: inset 0 -2px 5px rgba(0,0,0,.1);
|
40
|
+
}
|
41
|
+
|
42
|
+
/* Nav links */
|
43
|
+
.blog-nav-item {
|
44
|
+
position: relative;
|
45
|
+
display: inline-block;
|
46
|
+
padding: 10px;
|
47
|
+
font-weight: 500;
|
48
|
+
color: #cdddeb;
|
49
|
+
}
|
50
|
+
.blog-nav-item:hover,
|
51
|
+
.blog-nav-item:focus {
|
52
|
+
color: #fff;
|
53
|
+
text-decoration: none;
|
54
|
+
}
|
55
|
+
|
56
|
+
/* Active state gets a caret at the bottom */
|
57
|
+
.blog-nav .active {
|
58
|
+
color: #fff;
|
59
|
+
}
|
60
|
+
.blog-nav .active:after {
|
61
|
+
position: absolute;
|
62
|
+
bottom: 0;
|
63
|
+
left: 50%;
|
64
|
+
width: 0;
|
65
|
+
height: 0;
|
66
|
+
margin-left: -5px;
|
67
|
+
vertical-align: middle;
|
68
|
+
content: " ";
|
69
|
+
border-right: 5px solid transparent;
|
70
|
+
border-bottom: 5px solid;
|
71
|
+
border-left: 5px solid transparent;
|
72
|
+
}
|
73
|
+
|
74
|
+
|
75
|
+
/*
|
76
|
+
* Blog name and description
|
77
|
+
*/
|
78
|
+
|
79
|
+
.blog-header {
|
80
|
+
padding-top: 20px;
|
81
|
+
padding-bottom: 20px;
|
82
|
+
}
|
83
|
+
.blog-title {
|
84
|
+
margin-top: 30px;
|
85
|
+
margin-bottom: 0;
|
86
|
+
font-size: 60px;
|
87
|
+
font-weight: normal;
|
88
|
+
}
|
89
|
+
.blog-description {
|
90
|
+
font-size: 20px;
|
91
|
+
color: #999;
|
92
|
+
}
|
93
|
+
|
94
|
+
|
95
|
+
/*
|
96
|
+
* Main column and sidebar layout
|
97
|
+
*/
|
98
|
+
|
99
|
+
.blog-main {
|
100
|
+
font-size: 18px;
|
101
|
+
line-height: 1.5;
|
102
|
+
}
|
103
|
+
|
104
|
+
/* Sidebar modules for boxing content */
|
105
|
+
.sidebar-module {
|
106
|
+
padding: 15px;
|
107
|
+
margin: 0 -15px 15px;
|
108
|
+
}
|
109
|
+
.sidebar-module-inset {
|
110
|
+
padding: 15px;
|
111
|
+
background-color: #f5f5f5;
|
112
|
+
border-radius: 4px;
|
113
|
+
}
|
114
|
+
.sidebar-module-inset p:last-child,
|
115
|
+
.sidebar-module-inset ul:last-child,
|
116
|
+
.sidebar-module-inset ol:last-child {
|
117
|
+
margin-bottom: 0;
|
118
|
+
}
|
119
|
+
|
120
|
+
|
121
|
+
/* Pagination */
|
122
|
+
.pager {
|
123
|
+
margin-bottom: 60px;
|
124
|
+
text-align: left;
|
125
|
+
}
|
126
|
+
.pager > li > a {
|
127
|
+
width: 140px;
|
128
|
+
padding: 10px 20px;
|
129
|
+
text-align: center;
|
130
|
+
border-radius: 30px;
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
/*
|
135
|
+
* Blog posts
|
136
|
+
*/
|
137
|
+
|
138
|
+
.blog-post {
|
139
|
+
margin-bottom: 60px;
|
140
|
+
}
|
141
|
+
.blog-post-title {
|
142
|
+
margin-bottom: 5px;
|
143
|
+
font-size: 40px;
|
144
|
+
}
|
145
|
+
.blog-post-meta {
|
146
|
+
margin-bottom: 20px;
|
147
|
+
color: #999;
|
148
|
+
}
|
149
|
+
|
150
|
+
|
151
|
+
/*
|
152
|
+
* Footer
|
153
|
+
*/
|
154
|
+
|
155
|
+
.blog-footer {
|
156
|
+
padding: 40px 0;
|
157
|
+
color: #999;
|
158
|
+
text-align: center;
|
159
|
+
background-color: #f9f9f9;
|
160
|
+
border-top: 1px solid #e5e5e5;
|
161
|
+
}
|
162
|
+
.blog-footer p:last-child {
|
163
|
+
margin-bottom: 0;
|
164
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module BlogController
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
def index
|
5
|
+
@posts = Post
|
6
|
+
|
7
|
+
if user_signed_in?
|
8
|
+
@posts = @posts.order('created_at DESC')
|
9
|
+
else
|
10
|
+
@posts = @posts.where(published: true)
|
11
|
+
@posts = @posts.order('published_at DESC')
|
12
|
+
end
|
13
|
+
|
14
|
+
@posts = @posts.paginate(page: params[:page], per_page: 1)
|
15
|
+
|
16
|
+
@home_page_stylesheets = ['home_page/application', 'home_page_blog/posts']
|
17
|
+
|
18
|
+
render 'posts/index', layout: 'home_page_blog/application'
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class PostsController < ApplicationController
|
2
|
+
include BlogController
|
3
|
+
|
4
|
+
before_filter :authenticate_user!, only: [:new, :create, :edit, :update, :destroy]
|
5
|
+
before_filter :find_resource, only: [:show, :edit, :update, :publish, :unpublish, :destroy]
|
6
|
+
before_filter :show_breadcrumbs, only: [:new, :show, :edit]
|
7
|
+
|
8
|
+
def show
|
9
|
+
@home_page_stylesheets = ['home_page/application', 'home_page_blog/posts']
|
10
|
+
|
11
|
+
render layout: 'home_page_blog/application'
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@post = Post.new(params[:post])
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@post = Post.new(params[:post])
|
20
|
+
@post.user = current_user
|
21
|
+
|
22
|
+
if @post.save
|
23
|
+
redirect_to @post, notice: t('general.form.successfully_created')
|
24
|
+
else
|
25
|
+
render :new
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def edit
|
30
|
+
end
|
31
|
+
|
32
|
+
def update
|
33
|
+
if @post.update_attributes(params[:post])
|
34
|
+
redirect_to @post, notice: t('general.form.successfully_updated')
|
35
|
+
else
|
36
|
+
render :edit
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def publish
|
41
|
+
options = {}
|
42
|
+
|
43
|
+
if @post.publish
|
44
|
+
options[:notice] = t('posts.publish.successful')
|
45
|
+
else
|
46
|
+
options[:alert] = t('posts.publish.unsuccessful')
|
47
|
+
end
|
48
|
+
|
49
|
+
redirect_to posts_path, options
|
50
|
+
end
|
51
|
+
|
52
|
+
def unpublish
|
53
|
+
options = {}
|
54
|
+
|
55
|
+
if @post.unpublish
|
56
|
+
options[:notice] = t('posts.unpublish.successful')
|
57
|
+
else
|
58
|
+
options[:alert] = t('posts.unpublish.unsuccessful')
|
59
|
+
end
|
60
|
+
|
61
|
+
redirect_to posts_path, options
|
62
|
+
end
|
63
|
+
|
64
|
+
def destroy
|
65
|
+
@post.destroy
|
66
|
+
|
67
|
+
redirect_to posts_path, notice: t('general.form.destroyed')
|
68
|
+
end
|
69
|
+
|
70
|
+
def resource
|
71
|
+
@post
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def find_resource
|
77
|
+
@post = Post.friendly.find(params[:id])
|
78
|
+
end
|
79
|
+
end
|
data/app/models/post.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class Post < ActiveRecord::Base
|
2
|
+
belongs_to :user
|
3
|
+
|
4
|
+
scope :published, -> { where(published: true) }
|
5
|
+
|
6
|
+
validates :user_id, presence: true
|
7
|
+
validates :title, presence: true
|
8
|
+
validates :body, presence: true
|
9
|
+
|
10
|
+
attr_accessible :title, :summary, :body
|
11
|
+
|
12
|
+
extend FriendlyId
|
13
|
+
|
14
|
+
friendly_id :title, use: :slugged
|
15
|
+
|
16
|
+
before_create do |article|
|
17
|
+
article.summary = article.helpers.truncate(article.body, length: 143) unless article.summary.present?
|
18
|
+
end
|
19
|
+
|
20
|
+
def helpers
|
21
|
+
ActionController::Base.helpers
|
22
|
+
end
|
23
|
+
|
24
|
+
def publish
|
25
|
+
self.published = true
|
26
|
+
self.published_at = Time.now
|
27
|
+
save
|
28
|
+
end
|
29
|
+
|
30
|
+
def unpublish
|
31
|
+
self.published = false
|
32
|
+
self.published_at = nil
|
33
|
+
save
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<%= render partial: 'layouts/shared/head' %>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<%= render partial: 'layouts/shared/navigation' %>
|
8
|
+
|
9
|
+
<div class="container">
|
10
|
+
<%= render partial: 'layouts/shared/flash' %>
|
11
|
+
|
12
|
+
<div class="blog-header">
|
13
|
+
<% if @show_breadcrumbs %>
|
14
|
+
<%= breadcrumbs %><br/>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<h1 class="blog-title"><%= t 'general.blog.title' %></h1>
|
18
|
+
<p class="lead blog-description"><%= t 'general.blog.sub_title' %></p>
|
19
|
+
</div>
|
20
|
+
|
21
|
+
<div class="row">
|
22
|
+
|
23
|
+
<div class="col-sm-8 blog-main">
|
24
|
+
<%= yield %>
|
25
|
+
</div><!-- /.blog-main -->
|
26
|
+
|
27
|
+
<div class="col-sm-3 col-sm-offset-1 blog-sidebar">
|
28
|
+
<%= yield :sidebar %>
|
29
|
+
</div><!-- /.blog-sidebar -->
|
30
|
+
|
31
|
+
</div><!-- /.row -->
|
32
|
+
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<footer class="blog-footer">
|
36
|
+
<p>
|
37
|
+
<%= raw t('general.powered_by_home_page_software', link: link_to('Home-Page.Software', 'http://Home-Page.Software')) %>
|
38
|
+
</p>
|
39
|
+
<p>
|
40
|
+
<%= raw t(
|
41
|
+
'general.blog.template_built_by',
|
42
|
+
twitter_bootstrap_link: '<a href="http://getbootstrap.com">Bootstrap</a>',
|
43
|
+
author_link: '<a href="https://twitter.com/mdo">@mdo</a>'
|
44
|
+
) %>
|
45
|
+
</p>
|
46
|
+
<p>
|
47
|
+
<a href="#"><%= t('general.back_to_top') %></a>
|
48
|
+
</p>
|
49
|
+
</footer>
|
50
|
+
|
51
|
+
<%= render partial: 'layouts/shared/foot' %>
|
52
|
+
</body>
|
53
|
+
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= simple_form_for(
|
2
|
+
resource, url: resource.new_record? ? posts_path : post_path(resource),
|
3
|
+
method: resource.new_record? ? :post : :put, wrapper: :horizontal_form,
|
4
|
+
html: { class: 'form-horizontal', autocomplete: 'off' }
|
5
|
+
) do |f| %>
|
6
|
+
<%= devise_error_messages! %>
|
7
|
+
|
8
|
+
<%= f.input :title %>
|
9
|
+
<%= f.input :summary %>
|
10
|
+
<%= f.input :body %>
|
11
|
+
|
12
|
+
<div class="form-group">
|
13
|
+
<div class="col-sm-offset-3 col-sm-9">
|
14
|
+
<%= f.button :submit %>
|
15
|
+
</div>
|
16
|
+
</div>
|
17
|
+
<% end %>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<div class="blog-post">
|
2
|
+
<h2 class="blog-post-title"><%= post.title %></h2>
|
3
|
+
<p class="blog-post-meta"><%= (post.published_at || post.created_at).strftime('%B %e, %Y') %> by <%= post.user.full_name %></p>
|
4
|
+
|
5
|
+
<%= markdown post.body %>
|
6
|
+
|
7
|
+
<% if user_signed_in? %>
|
8
|
+
<ul class="pagination">
|
9
|
+
<li><%= link_to t('posts.edit.title'), edit_post_path(post) %></li>
|
10
|
+
<% if post.published? %>
|
11
|
+
<li>
|
12
|
+
<%= link_to t('posts.unpublish.title'), unpublish_post_path(post), method: :put %>
|
13
|
+
</li>
|
14
|
+
<% else %>
|
15
|
+
<li>
|
16
|
+
<%= link_to t('posts.publish.title'), publish_post_path(post), method: :put %>
|
17
|
+
</li>
|
18
|
+
<% end %>
|
19
|
+
<li>
|
20
|
+
<%= link_to t('general.destroy'), post_path(post), method: :delete, confirm: I18n.t('general.questions.are_you_sure') %>
|
21
|
+
</li>
|
22
|
+
</ul>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<% if @posts.none? %>
|
2
|
+
<p>
|
3
|
+
<%= t('posts.index.empty_collection') %>
|
4
|
+
</p>
|
5
|
+
<% else %>
|
6
|
+
<%= render partial: 'posts/post', collection: @posts %>
|
7
|
+
|
8
|
+
<%= will_paginate @posts, renderer: BootstrapPagination::Rails %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% if user_signed_in? %>
|
12
|
+
<p>
|
13
|
+
<%= link_to t('posts.new.title'), new_post_path, class: 'btn btn-default' %>
|
14
|
+
</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% content_for :sidebar do %>
|
18
|
+
<%= render partial: 'posts/sidebar' %>
|
19
|
+
<% end %>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<div class="blog-post">
|
2
|
+
<h2 class="blog-post-title">Sample blog post</h2>
|
3
|
+
<p class="blog-post-meta">January 1, 2014 by <a href="#">Mark</a></p>
|
4
|
+
|
5
|
+
<p>This blog post shows a few different types of content that's supported and styled with Bootstrap. Basic typography, images, and code are all supported.</p>
|
6
|
+
<hr>
|
7
|
+
<p>Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.</p>
|
8
|
+
<blockquote>
|
9
|
+
<p>Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong> ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
|
10
|
+
</blockquote>
|
11
|
+
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
|
12
|
+
<h2>Heading</h2>
|
13
|
+
<p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
|
14
|
+
<h3>Sub-heading</h3>
|
15
|
+
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
|
16
|
+
<pre><code>Example code block</code></pre>
|
17
|
+
<p>Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa.</p>
|
18
|
+
<h3>Sub-heading</h3>
|
19
|
+
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
|
20
|
+
<ul>
|
21
|
+
<li>Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</li>
|
22
|
+
<li>Donec id elit non mi porta gravida at eget metus.</li>
|
23
|
+
<li>Nulla vitae elit libero, a pharetra augue.</li>
|
24
|
+
</ul>
|
25
|
+
<p>Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.</p>
|
26
|
+
<ol>
|
27
|
+
<li>Vestibulum id ligula porta felis euismod semper.</li>
|
28
|
+
<li>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</li>
|
29
|
+
<li>Maecenas sed diam eget risus varius blandit sit amet non magna.</li>
|
30
|
+
</ol>
|
31
|
+
<p>Cras mattis consectetur purus sit amet fermentum. Sed posuere consectetur est at lobortis.</p>
|
32
|
+
</div><!-- /.blog-post -->
|
33
|
+
|
34
|
+
<div class="blog-post">
|
35
|
+
<h2 class="blog-post-title">Another blog post</h2>
|
36
|
+
<p class="blog-post-meta">December 23, 2013 by <a href="#">Jacob</a></p>
|
37
|
+
|
38
|
+
<p>Cum sociis natoque penatibus et magnis <a href="#">dis parturient montes</a>, nascetur ridiculus mus. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Sed posuere consectetur est at lobortis. Cras mattis consectetur purus sit amet fermentum.</p>
|
39
|
+
<blockquote>
|
40
|
+
<p>Curabitur blandit tempus porttitor. <strong>Nullam quis risus eget urna mollis</strong> ornare vel eu leo. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
|
41
|
+
</blockquote>
|
42
|
+
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
|
43
|
+
<p>Vivamus sagittis lacus vel augue laoreet rutrum faucibus dolor auctor. Duis mollis, est non commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. Morbi leo risus, porta ac consectetur ac, vestibulum at eros.</p>
|
44
|
+
</div><!-- /.blog-post -->
|
45
|
+
|
46
|
+
<div class="blog-post">
|
47
|
+
<h2 class="blog-post-title">New feature</h2>
|
48
|
+
<p class="blog-post-meta">December 14, 2013 by <a href="#">Chris</a></p>
|
49
|
+
|
50
|
+
<p>Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Aenean lacinia bibendum nulla sed consectetur. Etiam porta sem malesuada magna mollis euismod. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
|
51
|
+
<ul>
|
52
|
+
<li>Praesent commodo cursus magna, vel scelerisque nisl consectetur et.</li>
|
53
|
+
<li>Donec id elit non mi porta gravida at eget metus.</li>
|
54
|
+
<li>Nulla vitae elit libero, a pharetra augue.</li>
|
55
|
+
</ul>
|
56
|
+
<p>Etiam porta <em>sem malesuada magna</em> mollis euismod. Cras mattis consectetur purus sit amet fermentum. Aenean lacinia bibendum nulla sed consectetur.</p>
|
57
|
+
<p>Donec ullamcorper nulla non metus auctor fringilla. Nulla vitae elit libero, a pharetra augue.</p>
|
58
|
+
</div><!-- /.blog-post -->
|
59
|
+
|
60
|
+
<nav>
|
61
|
+
<ul class="pager">
|
62
|
+
<li><a href="#">Previous</a></li>
|
63
|
+
<li><a href="#">Next</a></li>
|
64
|
+
</ul>
|
65
|
+
</nav>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
en:
|
2
|
+
posts:
|
3
|
+
index:
|
4
|
+
title: Posts
|
5
|
+
empty_collection: No posts available.
|
6
|
+
about_dummy: Dummy.
|
7
|
+
|
8
|
+
new:
|
9
|
+
title: New Post
|
10
|
+
edit:
|
11
|
+
title: Edit Post
|
12
|
+
publish:
|
13
|
+
title: 'Publish'
|
14
|
+
successful: Post has been successfully published.
|
15
|
+
unsuccessful: Post could not be published!
|
16
|
+
unpublish:
|
17
|
+
title: 'Unpublish'
|
18
|
+
successful: Post has been successfully unpublished.
|
19
|
+
unsuccessful: Post could not be unpublished!
|
20
|
+
|
21
|
+
activerecord:
|
22
|
+
models:
|
23
|
+
post: Post
|
24
|
+
|
25
|
+
attributes:
|
26
|
+
post:
|
27
|
+
title: Title
|
28
|
+
summary: Summary
|
29
|
+
body: Body
|
30
|
+
published: Published?
|
data/config/routes.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateInitialBlogSchema < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :posts do |t|
|
4
|
+
t.integer :user_id
|
5
|
+
t.string :title
|
6
|
+
t.string :slug
|
7
|
+
t.string :summary
|
8
|
+
t.text :body
|
9
|
+
t.boolean :published, default: false
|
10
|
+
t.datetime :published_at
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
|
14
|
+
add_index :posts, :slug, unique: true
|
15
|
+
add_index :posts, :published
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module HomePageBlog
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
config.autoload_paths << File.expand_path("../../../app/models/concerns", __FILE__)
|
4
|
+
config.autoload_paths << File.expand_path("../../../app/controllers/concerns", __FILE__)
|
5
|
+
config.i18n.load_path += Dir[File.expand_path("../../../config/locales/**/*.{rb,yml}", __FILE__)]
|
6
|
+
|
7
|
+
config.to_prepare do
|
8
|
+
Rails.application.config.assets.precompile += %w(
|
9
|
+
home_page_blog/*
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module HomePageBlog
|
2
|
+
module Navigation
|
3
|
+
def self.menu_code(resource)
|
4
|
+
case resource
|
5
|
+
when :posts
|
6
|
+
Proc.new do |primary, options|
|
7
|
+
primary.item :posts, I18n.t('posts.index.title'), posts_path do |posts|
|
8
|
+
posts.item :new, I18n.t('general.new'), new_post_path
|
9
|
+
|
10
|
+
unless (@post.new_record? rescue true)
|
11
|
+
posts.item :show, @post.title, post_path(@post) do |post|
|
12
|
+
if user_signed_in?
|
13
|
+
post.item :destroy, I18n.t('general.destroy'), post_path(@post), method: :delete, confirm: I18n.t('general.questions.are_you_sure')
|
14
|
+
end
|
15
|
+
|
16
|
+
post.item :show, I18n.t('general.details'), "#{post_path(@post)}#top"
|
17
|
+
post.item :edit, I18n.t('general.edit'), edit_post_path(@post) if user_signed_in?
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: home_page_blog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mathias Gawlista
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: home_page
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.4
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mysql2
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Blog module for home_page gem.
|
56
|
+
email:
|
57
|
+
- gawlista@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- MIT-LICENSE
|
63
|
+
- README.rdoc
|
64
|
+
- Rakefile
|
65
|
+
- app/assets/stylesheets/home_page_blog/posts.css
|
66
|
+
- app/controllers/concerns/blog_controller.rb
|
67
|
+
- app/controllers/home_controller.rb
|
68
|
+
- app/controllers/posts_controller.rb
|
69
|
+
- app/models/post.rb
|
70
|
+
- app/views/layouts/home_page_blog/application.html.erb
|
71
|
+
- app/views/posts/_form.html.erb
|
72
|
+
- app/views/posts/_post.html.erb
|
73
|
+
- app/views/posts/_sidebar.html.erb
|
74
|
+
- app/views/posts/edit.html.erb
|
75
|
+
- app/views/posts/index.html.erb
|
76
|
+
- app/views/posts/index.txt
|
77
|
+
- app/views/posts/new.html.erb
|
78
|
+
- app/views/posts/show.html.erb
|
79
|
+
- app/views/posts/sidebar/_about.html.erb
|
80
|
+
- app/views/posts/sidebar/_social_links.html.erb
|
81
|
+
- config/locales/general/en.yml
|
82
|
+
- config/locales/resources/post/en.yml
|
83
|
+
- config/locales/resources/post_archive/en.yml
|
84
|
+
- config/routes.rb
|
85
|
+
- db/migrate/20150307194234_create_initial_blog_schema.rb
|
86
|
+
- lib/home_page_blog.rb
|
87
|
+
- lib/home_page_blog/engine.rb
|
88
|
+
- lib/home_page_blog/navigation.rb
|
89
|
+
- lib/home_page_blog/version.rb
|
90
|
+
- lib/tasks/home_page_blog_tasks.rake
|
91
|
+
homepage: http://Blog.Home-Page.Software
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Blog module for home_page gem.
|
115
|
+
test_files: []
|