grindstone 0.0.0 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/grindstone/application.js +13 -0
- data/app/assets/javascripts/grindstone/posts.js +2 -0
- data/app/controllers/grindstone/application_controller.rb +4 -0
- data/app/controllers/grindstone/posts_controller.rb +24 -0
- data/app/helpers/grindstone/application_helper.rb +4 -0
- data/app/models/grindstone/author.rb +6 -0
- data/app/models/grindstone/comment.rb +6 -0
- data/app/models/grindstone/post.rb +6 -0
- data/app/views/grindstone/posts/index.html.erb +23 -0
- data/app/views/grindstone/posts/partials/_comments.html.erb +8 -0
- data/app/views/grindstone/posts/partials/_head.html.erb +16 -0
- data/app/views/grindstone/posts/show.html.erb +19 -0
- data/app/views/layouts/grindstone/application.html.erb +14 -0
- data/config/initializers/rails_admin.rb +2 -0
- data/config/initializers/will_paginate.rb +15 -0
- data/config/routes.rb +5 -0
- data/lib/generators/grindstone/install_generator.rb +26 -0
- data/lib/generators/grindstone/templates/20090106022023_create_authors.erb +9 -0
- data/lib/generators/grindstone/templates/20090106022024_create_posts.erb +12 -0
- data/lib/generators/grindstone/templates/20090106022025_create_comments.erb +13 -0
- data/lib/generators/grindstone/templates/initializer.erb +5 -0
- data/lib/generators/grindstone/utils.rb +21 -0
- data/lib/grindstone.rb +17 -5
- data/lib/grindstone/engine.rb +5 -0
- data/lib/grindstone/version.rb +3 -0
- data/lib/tasks/grindstone_tasks.rake +31 -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 +15 -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/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -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 +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -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 +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/grindstone_test.rb +7 -0
- data/test/integration/navigation_test.rb +8 -0
- data/test/test_helper.rb +21 -0
- metadata +168 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac486612cf1e25f2da7d0c6c43984ef454b62794
|
4
|
+
data.tar.gz: 9c1d638657fc28fcd9c731af8011028dd2f06a6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 140e9e674e141bdc485d02818242e47a7171da1ce054d5ddac3c28b4ae718b4f8d97a45109a630d19abb306dcc091da4c0535fee0b3b052966510b2236ab908e
|
7
|
+
data.tar.gz: b1bc63fbd57321cca44134e93b6bcdc80872db07f9aefa3ba5cbfa8cf6337798526c217df5d088eb48c9095fee354b7c76475e3774ceabcf2097c435ca64c189
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
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 = 'Grindstone'
|
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
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
30
|
+
t.libs << 'lib'
|
31
|
+
t.libs << 'test'
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
33
|
+
t.verbose = false
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
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 any plugin's vendor/assets/javascripts directory 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/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Grindstone::PostsController < ApplicationController
|
2
|
+
before_action :set_post, only: [:show]
|
3
|
+
|
4
|
+
POST = Grindstone::Post
|
5
|
+
|
6
|
+
def index
|
7
|
+
post_count = params[:post_count] || 10
|
8
|
+
begin
|
9
|
+
@posts = Grindstone::Post.paginate(:page => params[:page],
|
10
|
+
:per_page => post_count)
|
11
|
+
rescue NoMethodError
|
12
|
+
@posts = POST.all
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def show
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def set_post
|
22
|
+
@post = POST.find(params[:id])
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<%= render "grindstone/posts/partials/head" %>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<div class="site-container row">
|
8
|
+
<h1><%= Grindstone.config.blog_title %></h1>
|
9
|
+
<h4><%= Grindstone.config.blog_description %></h4>
|
10
|
+
<% @posts.each do |post| %>
|
11
|
+
<h2><%= post.title %></h2>
|
12
|
+
<h3><%= post.grindstone_author.name %></h3>
|
13
|
+
<i><%= post.created_at %></i>
|
14
|
+
<div><%= post.body %></div>
|
15
|
+
<%= link_to 'Show', post %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= will_paginate @posts, :page_links => false %>
|
19
|
+
|
20
|
+
<footer><%= Grindstone.config.blog_footer %></footer>
|
21
|
+
</div>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!-- Meta -->
|
2
|
+
<meta charset="utf-8">
|
3
|
+
<meta name="keywords" content="blog" />
|
4
|
+
<meta name="description" content="Blog">
|
5
|
+
|
6
|
+
<title><%= Grindstone.config.blog_title %></title>
|
7
|
+
|
8
|
+
<!-- Mobile Metas -->
|
9
|
+
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height" />
|
10
|
+
|
11
|
+
<!-- Favicon -->
|
12
|
+
<link rel="shortcut icon" href="">
|
13
|
+
|
14
|
+
<!-- Styles -->
|
15
|
+
<link rel="stylesheet" type="text/css"
|
16
|
+
href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.0.1/css/foundation.min.css">
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<%= render "grindstone/posts/partials/head" %>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<div class="site-container row">
|
8
|
+
<h1><%= Grindstone.config.blog_title %></h1>
|
9
|
+
<h2><%= @post.title %></h2>
|
10
|
+
<h3><%= @post.grindstone_author.name %></h3>
|
11
|
+
<i><%= @post.created_at %></i>
|
12
|
+
<div><%= @post.body %></div>
|
13
|
+
<!-- <%= render "grindstone/posts/partials/comments" %> -->
|
14
|
+
<%= link_to 'Back', posts_path %>
|
15
|
+
|
16
|
+
<footer><%= Grindstone.config.blog_footer %></footer>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Grindstone</title>
|
5
|
+
<%= stylesheet_link_tag "grindstone/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "grindstone/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
if defined?(WillPaginate)
|
2
|
+
module WillPaginate
|
3
|
+
module ActiveRecord
|
4
|
+
module RelationMethods
|
5
|
+
def per(value = nil) per_page(value) end
|
6
|
+
def total_count() count end
|
7
|
+
def first_page?() self == first end
|
8
|
+
def last_page?() self == last end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
module CollectionMethods
|
12
|
+
alias_method :num_pages, :total_pages
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require File.expand_path '../utils', __FILE__
|
3
|
+
|
4
|
+
module Grindstone
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path '../templates', __FILE__
|
7
|
+
include Generators::Utils::InstanceMethods
|
8
|
+
|
9
|
+
argument :_namespace, type: :string, required: false,
|
10
|
+
desc: 'Grindstone url namespace'
|
11
|
+
desc 'Creates a Grindstone initializer to your application.'
|
12
|
+
|
13
|
+
def install
|
14
|
+
namespace = ask_for 'Where do you want to mount Grindstone?', 'blog',
|
15
|
+
_namespace
|
16
|
+
route "mount Grindstone::Engine => '/#{namespace}', as: 'grindstone'"
|
17
|
+
template 'initializer.erb', 'config/initializers/grindstone.rb'
|
18
|
+
template '20090106022023_create_authors.erb',
|
19
|
+
'db/migrate/20090106022023_create_authors.rb'
|
20
|
+
template '20090106022024_create_posts.erb',
|
21
|
+
'db/migrate/20090106022023_create_posts.rb'
|
22
|
+
template '20090106022025_create_comments.erb',
|
23
|
+
'db/migrate/20090106022025_create_comments.rb'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreatePosts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :grindstone_posts do |t|
|
4
|
+
t.string :title
|
5
|
+
t.text :body
|
6
|
+
|
7
|
+
t.timestamps null: true
|
8
|
+
end
|
9
|
+
add_column :grindstone_posts, :grindstone_author_id, :integer
|
10
|
+
add_foreign_key :grindstone_posts, :grindstone_authors
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateComments < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :grindstone_comments do |t|
|
4
|
+
t.string :title
|
5
|
+
t.string :username
|
6
|
+
t.text :body
|
7
|
+
|
8
|
+
t.timestamps null: true
|
9
|
+
end
|
10
|
+
add_column :grindstone_comments, :grindstone_post_id, :integer
|
11
|
+
add_foreign_key :grindstone_comments, :grindstone_posts
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Replicated from rails_admin gem
|
2
|
+
|
3
|
+
module Grindstone
|
4
|
+
module Generators
|
5
|
+
module Utils
|
6
|
+
module InstanceMethods
|
7
|
+
def display(output, color = :green)
|
8
|
+
say(" - #{output}", color)
|
9
|
+
end
|
10
|
+
|
11
|
+
def ask_for(wording, default_value = nil, override_if_present_value = nil)
|
12
|
+
if override_if_present_value.present?
|
13
|
+
display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value
|
14
|
+
else
|
15
|
+
ask(" ? #{wording} Press <enter> for [#{default_value}] >", :yellow).presence || default_value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/grindstone.rb
CHANGED
@@ -1,7 +1,19 @@
|
|
1
|
-
|
1
|
+
require 'grindstone/engine'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
module Grindstone
|
4
|
+
class Config
|
5
|
+
attr_accessor :blog_title, :blog_description, :blog_footer
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
|
+
def self.config
|
9
|
+
unless @grindstone_config
|
10
|
+
@grindstone_config = Config.new
|
11
|
+
end
|
12
|
+
|
13
|
+
yield @grindstone_config if block_given?
|
14
|
+
@grindstone_config
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
@grindstone_config = nil
|
19
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
namespace :grindstone do
|
4
|
+
desc "Create Grindstone migrations"
|
5
|
+
task :create_migrations do
|
6
|
+
|
7
|
+
# Get the Grindstone dir
|
8
|
+
spec = Gem::Specification.find_by_name 'grindstone'
|
9
|
+
|
10
|
+
# Set the destination
|
11
|
+
dest_dir = "#{Rails.root}/db/migrate"
|
12
|
+
|
13
|
+
unless File.directory?(dest_dir)
|
14
|
+
FileUtils.mkdir_p(dest_dir)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Read the source
|
18
|
+
Dir.glob("#{spec.gem_dir}/db/migrate/*.rb").each do |migration|
|
19
|
+
filename = migration.split('/').last
|
20
|
+
filepath = "#{dest_dir}/#{filename}"
|
21
|
+
|
22
|
+
puts migration, filepath
|
23
|
+
|
24
|
+
# Copy the file
|
25
|
+
File.open(filepath, 'w')
|
26
|
+
FileUtils::cp migration, filepath, :verbose => true
|
27
|
+
end
|
28
|
+
|
29
|
+
puts 'Grindstone: Copied Migrations'
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|