fuel 0.2.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/fuel/application.js +13 -0
- data/app/assets/javascripts/fuel/posts.js +2 -0
- data/app/assets/stylesheets/fuel/application.css +57 -0
- data/app/assets/stylesheets/fuel/posts.css +44 -0
- data/app/assets/stylesheets/fuel/reset.css +48 -0
- data/app/controllers/fuel/admin/posts_controller.rb +65 -0
- data/app/controllers/fuel/application_controller.rb +4 -0
- data/app/controllers/fuel/posts_controller.rb +29 -0
- data/app/helpers/fuel/application_helper.rb +33 -0
- data/app/helpers/fuel/posts_helper.rb +4 -0
- data/app/models/fuel/post.rb +22 -0
- data/app/views/fuel/admin/posts/_form.html.erb +23 -0
- data/app/views/fuel/admin/posts/edit.html.erb +5 -0
- data/app/views/fuel/admin/posts/index.html.erb +25 -0
- data/app/views/fuel/admin/posts/new.html.erb +5 -0
- data/app/views/fuel/posts/_post.html.erb +16 -0
- data/app/views/fuel/posts/index.html.erb +19 -0
- data/app/views/fuel/posts/show.html.erb +9 -0
- data/app/views/layouts/fuel/application.html.erb +14 -0
- data/config/routes.rb +11 -0
- data/db/migrate/20140122011655_create_fuel_posts.rb +15 -0
- data/lib/fuel/configuration.rb +14 -0
- data/lib/fuel/engine.rb +5 -0
- data/lib/fuel/version.rb +3 -0
- data/lib/fuel.rb +15 -0
- data/lib/generators/fuel/install_generator.rb +15 -0
- data/lib/generators/fuel/views_generator.rb +17 -0
- data/lib/generators/templates/fuel.rb +12 -0
- data/lib/tasks/fuel_tasks.rake +4 -0
- data/test/controllers/fuel/posts_controller_test.rb +9 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/friendly_id.rb +88 -0
- data/test/dummy/config/initializers/fuel.rb +12 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20140123225741_create_fuel_posts.fuel.rb +16 -0
- data/test/dummy/db/migrate/20140123230639_create_friendly_id_slugs.rb +15 -0
- data/test/dummy/db/schema.rb +42 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +23496 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/014dac3985653ba3455824e5bdaf93bd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/03ac2f751ed77389257433b768f934c3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/05c5819ebb446d33153d21337d3a20ad +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3ebee12608c20315d8de4675220e3d04 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/741e06bd7a3e5bc32d44a86b156237b4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7cb8cf7fca54a9d0c860db5e7a874fa9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9501761eef62112c4a992aa52331b52f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/970522fbbd63cf689683466c5196857f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9e6bbc6ad4182b36488ed894b2cf25af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9f4599bbfc23ec621d87974b1cb749e3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9f6c8d6fbf570cfe1a06179461b0de2d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a97bc057d70e3604312a80f169e9e6e9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bfa298bb2836528bc682672f2a549707 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c21e7a5dd39166b6f02a10131e7b60a5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c78d634ffc32ae4fadbe52ac7ca08aac +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d7fb93600298f6787c9defd51a75aeb5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d9ff247d231468f7dc28844500bc20aa +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f089ae120c22843da39b636bfc4b8e01 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/fixtures/fuel/posts.yml +17 -0
- data/test/fuel_test.rb +7 -0
- data/test/helpers/fuel/posts_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/fuel/post_test.rb +9 -0
- data/test/test_helper.rb +15 -0
- metadata +275 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 2ce38c23bf5558e81f4d695c6997905bf31cd756
|
|
4
|
+
data.tar.gz: c768e128253d0732119526ada53b4c01df75e492
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9bcd3cedab634af6f3bf24c240f4472ec5f510e3a6ad9c40b9f8db8086ae3a8d82652d6bee5f5b033a5f8b1ec0726ef581c5ac3615ce488923c8c10bf35a6fc5
|
|
7
|
+
data.tar.gz: 5dcf705611b964df73deffa2d1732468cdb482e72a086c1f846e26c88345a9c98f10723d7ba2f4e314bcc16a1f37707272745649b75766ebda52bcb8a78bccc6
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2014 YOURNAME
|
|
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,34 @@
|
|
|
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 = 'Fuel'
|
|
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("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rake/testtask'
|
|
25
|
+
|
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
|
27
|
+
t.libs << 'lib'
|
|
28
|
+
t.libs << 'test'
|
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
|
30
|
+
t.verbose = false
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
task default: :test
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
|
10
|
+
*
|
|
11
|
+
*= require_self
|
|
12
|
+
*= require_posts
|
|
13
|
+
*/
|
|
14
|
+
/* ALL FUEL */
|
|
15
|
+
.fuel h1 { margin-bottom: 10px; font-size: 2.5em; }
|
|
16
|
+
|
|
17
|
+
/* ADMIN */
|
|
18
|
+
.fuel-admin { margin-top: 20px; width: 90%; float: left; margin-left: 4%; font-family: sans-serif; margin-bottom: 100px;}
|
|
19
|
+
.fuel-admin input[type="text"], textarea {
|
|
20
|
+
width: 50%;
|
|
21
|
+
height: 2em;
|
|
22
|
+
font-size: 1.2em;
|
|
23
|
+
margin-top: 5px;
|
|
24
|
+
margin-bottom: 20px;
|
|
25
|
+
display: block;
|
|
26
|
+
}
|
|
27
|
+
.fuel-admin textarea {
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: 400px;
|
|
30
|
+
}
|
|
31
|
+
.fuel-admin label {
|
|
32
|
+
font-weight: bold;
|
|
33
|
+
font-size: 1.5em;
|
|
34
|
+
}
|
|
35
|
+
.fuel-admin input[type="submit"] { font-size: 2em; font-weight: bold; }
|
|
36
|
+
.fuel-admin h1 { margin-top: 40px; margin-bottom: 30px;}
|
|
37
|
+
.fuel-admin .markdown{ width: 400px; float: left; }
|
|
38
|
+
.fuel-admin tr { text-align: left; border-bottom: 1px solid #ddd; }
|
|
39
|
+
.fuel-admin table { border: thin solid #ccc; margin-top: 20px;}
|
|
40
|
+
.fuel-admin th { padding: 2px 20px; border-bottom: 1px solid #444; font-size: 1.2em; font-weight: bold;}
|
|
41
|
+
.fuel-admin td { padding: 10px 20px; }
|
|
42
|
+
.fuel-admin td.date { width: 140px; }
|
|
43
|
+
.fuel-admin td.post { width: 500px; }
|
|
44
|
+
.fuel-admin .draft { color: green; }
|
|
45
|
+
.fuel-admin .save{ margin-left: 40px; background-color: #777; }
|
|
46
|
+
.fuel-admin .post-contact-area{ margin-top: 50px; }
|
|
47
|
+
.fuel-admin .twitter-follow-button{ margin-top: 5px; }
|
|
48
|
+
.fuel-admin fieldset { border: none; margin-top: none; }
|
|
49
|
+
|
|
50
|
+
/* Blog */
|
|
51
|
+
.fuel-posts .fuel_post_title { font-size: 1.8em; margin-top: 20px; }
|
|
52
|
+
|
|
53
|
+
.fuel-posts h1, .fuel-posts h2, .fuel-posts h3, .fuel-posts h4, .fuel-posts h5, .fuel-posts h6 { font-weight: bold; }
|
|
54
|
+
.fuel-posts { padding: 20px; }
|
|
55
|
+
.fuel-posts .fuel_post_additional_info { margin-top: 5px; display: block; }
|
|
56
|
+
.fuel-posts .fuel_post_author, .fuel_post_date { display: inline; font-size: 1em; color: #999;}
|
|
57
|
+
.fuel-posts .fuel_post_content { margin-top: 20px; }
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/* ALL FUEL */
|
|
2
|
+
.fuel h1 { margin-bottom: 10px; font-size: 2.5em; }
|
|
3
|
+
|
|
4
|
+
/* ADMIN */
|
|
5
|
+
.fuel-admin { margin-top: 20px; width: 90%; float: left; margin-left: 4%; font-family: sans-serif; margin-bottom: 100px;}
|
|
6
|
+
.fuel-admin input[type="text"], textarea {
|
|
7
|
+
width: 50%;
|
|
8
|
+
height: 2em;
|
|
9
|
+
font-size: 1.2em;
|
|
10
|
+
margin-top: 5px;
|
|
11
|
+
margin-bottom: 20px;
|
|
12
|
+
display: block;
|
|
13
|
+
}
|
|
14
|
+
.fuel-admin textarea {
|
|
15
|
+
width: 100%;
|
|
16
|
+
height: 400px;
|
|
17
|
+
}
|
|
18
|
+
.fuel-admin label {
|
|
19
|
+
font-weight: bold;
|
|
20
|
+
font-size: 1.5em;
|
|
21
|
+
}
|
|
22
|
+
.fuel-admin input[type="submit"] { font-size: 2em; font-weight: bold; }
|
|
23
|
+
.fuel-admin h1 { margin-top: 40px; margin-bottom: 30px;}
|
|
24
|
+
.fuel-admin .markdown{ width: 400px; float: left; }
|
|
25
|
+
.fuel-admin tr { text-align: left; border-bottom: 1px solid #ddd; }
|
|
26
|
+
.fuel-admin table { border: thin solid #ccc; margin-top: 20px;}
|
|
27
|
+
.fuel-admin th { padding: 2px 20px; border-bottom: 1px solid #444; font-size: 1.2em; font-weight: bold;}
|
|
28
|
+
.fuel-admin td { padding: 10px 20px; }
|
|
29
|
+
.fuel-admin td.date { width: 140px; }
|
|
30
|
+
.fuel-admin td.post { width: 500px; }
|
|
31
|
+
.fuel-admin .draft { color: green; }
|
|
32
|
+
.fuel-admin .save{ margin-left: 40px; background-color: #777; }
|
|
33
|
+
.fuel-admin .post-contact-area{ margin-top: 50px; }
|
|
34
|
+
.fuel-admin .twitter-follow-button{ margin-top: 5px; }
|
|
35
|
+
.fuel-admin fieldset { border: none; margin-top: none; }
|
|
36
|
+
|
|
37
|
+
/* Blog */
|
|
38
|
+
.fuel-posts .fuel_post_title { font-size: 1.8em; margin-top: 20px; }
|
|
39
|
+
|
|
40
|
+
.fuel-posts h1, .fuel-posts h2, .fuel-posts h3, .fuel-posts h4, .fuel-posts h5, .fuel-posts h6 { font-weight: bold; }
|
|
41
|
+
.fuel-posts { padding: 20px; }
|
|
42
|
+
.fuel-posts .fuel_post_additional_info { margin-top: 5px; display: block; }
|
|
43
|
+
.fuel-posts .fuel_post_author, .fuel_post_date { display: inline; font-size: 1em; color: #999;}
|
|
44
|
+
.fuel-posts .fuel_post_content { margin-top: 20px; }
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* http://meyerweb.com/eric/tools/css/reset/
|
|
2
|
+
v2.0 | 20110126
|
|
3
|
+
License: none (public domain)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
html, body, div, span, applet, object, iframe,
|
|
7
|
+
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
|
8
|
+
a, abbr, acronym, address, big, cite, code,
|
|
9
|
+
del, dfn, em, img, ins, kbd, q, s, samp,
|
|
10
|
+
small, strike, strong, sub, sup, tt, var,
|
|
11
|
+
b, u, i, center,
|
|
12
|
+
dl, dt, dd, ol, ul, li,
|
|
13
|
+
fieldset, form, label, legend,
|
|
14
|
+
table, caption, tbody, tfoot, thead, tr, th, td,
|
|
15
|
+
article, aside, canvas, details, embed,
|
|
16
|
+
figure, figcaption, footer, header, hgroup,
|
|
17
|
+
menu, nav, output, ruby, section, summary,
|
|
18
|
+
time, mark, audio, video {
|
|
19
|
+
margin: 0;
|
|
20
|
+
padding: 0;
|
|
21
|
+
border: 0;
|
|
22
|
+
font-size: 100%;
|
|
23
|
+
font: inherit;
|
|
24
|
+
vertical-align: baseline;
|
|
25
|
+
}
|
|
26
|
+
/* HTML5 display-role reset for older browsers */
|
|
27
|
+
article, aside, details, figcaption, figure,
|
|
28
|
+
footer, header, hgroup, menu, nav, section {
|
|
29
|
+
display: block;
|
|
30
|
+
}
|
|
31
|
+
body {
|
|
32
|
+
line-height: 1;
|
|
33
|
+
}
|
|
34
|
+
ol, ul {
|
|
35
|
+
list-style: none;
|
|
36
|
+
}
|
|
37
|
+
blockquote, q {
|
|
38
|
+
quotes: none;
|
|
39
|
+
}
|
|
40
|
+
blockquote:before, blockquote:after,
|
|
41
|
+
q:before, q:after {
|
|
42
|
+
content: '';
|
|
43
|
+
content: none;
|
|
44
|
+
}
|
|
45
|
+
table {
|
|
46
|
+
border-collapse: collapse;
|
|
47
|
+
border-spacing: 0;
|
|
48
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
class Admin::PostsController < ApplicationController
|
|
3
|
+
http_basic_authenticate_with name: "admin", password: "password"
|
|
4
|
+
|
|
5
|
+
def index
|
|
6
|
+
@posts = Fuel::Post.all
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def new
|
|
10
|
+
@post = Fuel::Post.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def create
|
|
14
|
+
# raise Fuel::Post.new.inspect
|
|
15
|
+
@post = Fuel::Post.new
|
|
16
|
+
@post.tag = post_params["tag"]
|
|
17
|
+
@post.author = post_params["author"]
|
|
18
|
+
@post.content = post_params["content"]
|
|
19
|
+
@post.title = post_params["title"]
|
|
20
|
+
update_published
|
|
21
|
+
|
|
22
|
+
if @post.save
|
|
23
|
+
redirect_to @post, notice: "Your blog post was successfully #{@message}."
|
|
24
|
+
else
|
|
25
|
+
render action: "new"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def edit
|
|
30
|
+
@post = Fuel::Post.find_by_slug(params[:id])
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def update
|
|
34
|
+
@post = Fuel::Post.find_by_slug(params[:id])
|
|
35
|
+
@post.tag = post_params["tag"]
|
|
36
|
+
@post.author = post_params["author"]
|
|
37
|
+
@post.content = post_params["content"]
|
|
38
|
+
@post.title = post_params["title"]
|
|
39
|
+
update_published
|
|
40
|
+
if @post.save
|
|
41
|
+
redirect_to admin_posts_path, notice: "Post was updated and #{@message}"
|
|
42
|
+
else
|
|
43
|
+
render action: "edit"
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy
|
|
48
|
+
@post = Fuel::Post.find_by_slug(params[:id])
|
|
49
|
+
@post.destroy
|
|
50
|
+
redirect_to admin_posts_path, notice: "Post was successfully deleted"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def post_params
|
|
56
|
+
params.require(:post).permit(:tag, :author, :content, :title)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def update_published
|
|
60
|
+
@post.published = params[:commit] == "Save Draft" ? false : true
|
|
61
|
+
@message = @post.published ? "posted" : "saved"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_dependency "fuel/application_controller"
|
|
2
|
+
|
|
3
|
+
module Fuel
|
|
4
|
+
class PostsController < ApplicationController
|
|
5
|
+
include ActionView::Helpers::TextHelper
|
|
6
|
+
layout Fuel.configuration.layout if Fuel.configuration.layout
|
|
7
|
+
before_filter :define_title
|
|
8
|
+
|
|
9
|
+
def define_title
|
|
10
|
+
@blog_title = Fuel.configuration.blog_title
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def index
|
|
14
|
+
@posts = Fuel::Post.where(published: true).order("created_at DESC").page(params[:page])
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def show
|
|
18
|
+
# delete || Fuel::Post.find_by_id(params[:id]) once done testing pagination
|
|
19
|
+
@post = Fuel::Post.find_by_slug(params[:id]) || Fuel::Post.find_by_id(params[:id])
|
|
20
|
+
@title = truncate_on_space(@post.title, 70)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def truncate_on_space(text, length)
|
|
26
|
+
truncate(text, length: length, separator: ' ')
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
module ApplicationHelper
|
|
3
|
+
|
|
4
|
+
def markdown(text)
|
|
5
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML,
|
|
6
|
+
:autolink => true, :space_after_headers => true)
|
|
7
|
+
raw markdown.render(text)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Can search for named routes directly in the main app, omitting
|
|
11
|
+
# the "main_app." prefix
|
|
12
|
+
def method_missing method, *args, &block
|
|
13
|
+
if main_app_url_helper?(method)
|
|
14
|
+
main_app.send(method, *args)
|
|
15
|
+
else
|
|
16
|
+
super
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def respond_to?(method)
|
|
21
|
+
main_app_url_helper?(method) or super
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def main_app_url_helper?(method)
|
|
27
|
+
Fuel.configuration.inline_main_app_named_routes and
|
|
28
|
+
(method.to_s.end_with?('_path') or method.to_s.end_with?('_url')) and
|
|
29
|
+
main_app.respond_to?(method)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
class Post < ActiveRecord::Base
|
|
3
|
+
extend FriendlyId
|
|
4
|
+
friendly_id :title, use: :slugged
|
|
5
|
+
|
|
6
|
+
if Rails.version[0].to_i < 4
|
|
7
|
+
attr_accessible :tag, :author, :content, :title
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
validates_presence_of :title, :content, :author
|
|
11
|
+
paginates_per 5
|
|
12
|
+
|
|
13
|
+
def should_generate_new_friendly_id?
|
|
14
|
+
new_record? #Don't generate new id on edit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def save_as_draft
|
|
18
|
+
self.published = false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%= form_for [:admin, @post] do |f| %>
|
|
2
|
+
<% if @post.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @post.errors.full_messages.each do |msg| %>
|
|
8
|
+
<li><%= msg %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
<%= f.label :title %>
|
|
14
|
+
<%= f.text_field :title %>
|
|
15
|
+
<%= f.label :tag %>
|
|
16
|
+
<%= f.text_field :tag %>
|
|
17
|
+
<%= f.label :author %>
|
|
18
|
+
<%= f.text_field :author %>
|
|
19
|
+
<%= f.label :content %>
|
|
20
|
+
<%= f.text_area :content %>
|
|
21
|
+
<%= f.submit 'Publish' %>
|
|
22
|
+
<%= f.submit 'Save Draft' %>
|
|
23
|
+
<% end %>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<div class="fuel fuel-admin index">
|
|
2
|
+
<h1>Blog Admin Panel</h1>
|
|
3
|
+
|
|
4
|
+
<%= link_to 'New Post', new_admin_post_path %> | <%= link_to 'View Blog', posts_path %>
|
|
5
|
+
<table class="table">
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>Published On</th>
|
|
9
|
+
<th>Title</th>
|
|
10
|
+
<th></th>
|
|
11
|
+
<th></th>
|
|
12
|
+
</tr>
|
|
13
|
+
</thead>
|
|
14
|
+
<tbody>
|
|
15
|
+
<% @posts.each do |post| %>
|
|
16
|
+
<tr>
|
|
17
|
+
<td><%= post.published ? post.created_at.strftime('%m/%d/%Y') : 'Draft' %></td>
|
|
18
|
+
<td><%= link_to post.title, post_path(post) %></td>
|
|
19
|
+
<td><%= link_to "Edit", edit_admin_post_path(post) %></td>
|
|
20
|
+
<td><%= link_to "Delete", admin_post_path(post), method: :delete, data: { confirm: "Are you sure you want to delete this post?" } %></td>
|
|
21
|
+
</tr>
|
|
22
|
+
<% end %>
|
|
23
|
+
</tbody>
|
|
24
|
+
</table>
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<div class="fuel_post_additional_info">
|
|
2
|
+
<!-- <span class="fuel_post_date"><%= post.created_at.strftime('%b %d, %Y') %> - </span> -->
|
|
3
|
+
<span class="fuel_post_author">By <%= post.author %></span>
|
|
4
|
+
</div>
|
|
5
|
+
<% if action_name == "show" %>
|
|
6
|
+
<div class="fuel_post_content">
|
|
7
|
+
<%= markdown(post.content).html_safe %>
|
|
8
|
+
</div>
|
|
9
|
+
<% else %>
|
|
10
|
+
<div class="fuel_post_content">
|
|
11
|
+
<%= markdown(truncate post.content, length: 800).html_safe %>
|
|
12
|
+
</div>
|
|
13
|
+
<% if post.content.length > 800 %>
|
|
14
|
+
<p><%= link_to 'Read more', post_url(post) %></p>
|
|
15
|
+
<% end %>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<div class="fuel fuel-posts">
|
|
2
|
+
<div class="tagline">
|
|
3
|
+
<h1 class="tagline"><%= link_to @blog_title, root_path %></h1>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
<% if @posts %>
|
|
7
|
+
<section class="posts">
|
|
8
|
+
<%= paginate @posts %>
|
|
9
|
+
<% @posts.each do |post| %>
|
|
10
|
+
<article class="fuel-post fuel-post-index">
|
|
11
|
+
<h2 class="fuel_post_title"><%= link_to post.title, post %></h2>
|
|
12
|
+
<%= render "fuel/posts/post", post: post %>
|
|
13
|
+
</article>
|
|
14
|
+
<% end %>
|
|
15
|
+
</section>
|
|
16
|
+
<% else %>
|
|
17
|
+
|
|
18
|
+
<% end %>
|
|
19
|
+
</div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="fuel fuel-posts">
|
|
2
|
+
<div class="tagline">
|
|
3
|
+
<h1 class="tagline"><%= link_to @blog_title, root_path %></h1>
|
|
4
|
+
</div>
|
|
5
|
+
<article class="fuel-post fuel-post-show">
|
|
6
|
+
<h2 class="fuel_post_title"><%= @post.title %></h2>
|
|
7
|
+
<%= render 'post', post: @post %>
|
|
8
|
+
</article>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Fuel</title>
|
|
5
|
+
<%= stylesheet_link_tag "fuel/application", media: "all" %>
|
|
6
|
+
<%= javascript_include_tag "fuel/application" %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
class CreateFuelPosts < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :fuel_posts do |t|
|
|
4
|
+
t.string :tag
|
|
5
|
+
t.string :author
|
|
6
|
+
t.text :content
|
|
7
|
+
t.string :title
|
|
8
|
+
t.string :slug
|
|
9
|
+
t.boolean :published, default: true
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
add_index :fuel_posts, :slug, unique: true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
class Configuration
|
|
3
|
+
|
|
4
|
+
# What kind of comments do you want to add to your blog ? (:active_record, :disqus or :no)
|
|
5
|
+
attr_accessor :layout, :inline_main_app_named_routes, :blog_title
|
|
6
|
+
|
|
7
|
+
def initialize
|
|
8
|
+
@layout = nil
|
|
9
|
+
@inline_main_app_named_routes = true
|
|
10
|
+
@blog_title = "Blog"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/fuel/engine.rb
ADDED
data/lib/fuel/version.rb
ADDED
data/lib/fuel.rb
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "fuel/engine"
|
|
2
|
+
require "redcarpet"
|
|
3
|
+
require "kaminari"
|
|
4
|
+
require "fuel/configuration"
|
|
5
|
+
require "friendly_id"
|
|
6
|
+
|
|
7
|
+
module Fuel
|
|
8
|
+
def self.configure(&block)
|
|
9
|
+
block.call(configuration)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.configuration
|
|
13
|
+
@configuration ||= Configuration.new
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
|
|
5
|
+
source_root File.expand_path('../../templates', __FILE__)
|
|
6
|
+
|
|
7
|
+
desc "Creates a Fuel initializer in config/initializers"
|
|
8
|
+
|
|
9
|
+
def copy_initializer
|
|
10
|
+
template "fuel.rb", "config/initializers/fuel.rb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Fuel
|
|
2
|
+
module Generators
|
|
3
|
+
|
|
4
|
+
class ViewsGenerator < Rails::Generators::Base
|
|
5
|
+
desc "Copies Fuel views to your application."
|
|
6
|
+
|
|
7
|
+
include Thor::Actions
|
|
8
|
+
|
|
9
|
+
source_root File.expand_path('../../../../app/views', __FILE__)
|
|
10
|
+
|
|
11
|
+
def copy_views
|
|
12
|
+
directory 'fuel', 'app/views/fuel'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|