miniblog 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.autotest +5 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.simplecov +13 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +20 -0
- data/Gemfile.4.1 +19 -0
- data/MIT-LICENSE +20 -0
- data/README.md +86 -0
- data/Rakefile +29 -0
- data/app/assets/images/crowdblog/.gitkeep +0 -0
- data/app/assets/javascripts/miniblog.js +7 -0
- data/app/assets/javascripts/miniblog/alerts.js +5 -0
- data/app/assets/javascripts/miniblog/form-errors.js +3 -0
- data/app/assets/stylesheets/application.css +3 -0
- data/app/assets/stylesheets/miniblog.css +5 -0
- data/app/assets/stylesheets/miniblog/bootstrap_and_overrides.css.scss +1 -0
- data/app/assets/stylesheets/miniblog/posts.css.scss +34 -0
- data/app/controllers/miniblog/admin/assets_controller.rb +20 -0
- data/app/controllers/miniblog/admin/base_controller.rb +7 -0
- data/app/controllers/miniblog/admin/posts_controller.rb +63 -0
- data/app/controllers/miniblog/admin/preview_controller.rb +8 -0
- data/app/controllers/miniblog/admin/states_controller.rb +11 -0
- data/app/controllers/miniblog/admin/transitions_controller.rb +22 -0
- data/app/controllers/miniblog/application_controller.rb +14 -0
- data/app/controllers/miniblog/posts_controller.rb +7 -0
- data/app/helpers/miniblog/admin/posts_helper.rb +18 -0
- data/app/helpers/miniblog/application_helper.rb +4 -0
- data/app/models/miniblog/asset.rb +7 -0
- data/app/models/miniblog/post.rb +135 -0
- data/app/models/miniblog/status_change_record.rb +6 -0
- data/app/models/miniblog/user.rb +32 -0
- data/app/presenters/miniblog/post_presenter.rb +13 -0
- data/app/uploaders/attachment_uploader.rb +48 -0
- data/app/views/layouts/miniblog/admin/base.html.erb +26 -0
- data/app/views/miniblog/admin/posts/_form.html.erb +10 -0
- data/app/views/miniblog/admin/posts/_form.html.slim +27 -0
- data/app/views/miniblog/admin/posts/_post.html.erb +14 -0
- data/app/views/miniblog/admin/posts/_post.html.slim +20 -0
- data/app/views/miniblog/admin/posts/edit.html.erb +19 -0
- data/app/views/miniblog/admin/posts/edit.html.slim +14 -0
- data/app/views/miniblog/admin/posts/index.html.erb +5 -0
- data/app/views/miniblog/admin/posts/new.html.erb +17 -0
- data/app/views/miniblog/admin/posts/new.html.slim +12 -0
- data/app/views/miniblog/application/_navbar.html.erb +19 -0
- data/app/views/miniblog/application/_notices.html.slim +6 -0
- data/app/views/miniblog/posts/_post.html.slim +4 -0
- data/app/views/miniblog/posts/index.html.slim +1 -0
- data/config/cucumber.yml +9 -0
- data/config/initializers/date_formats.rb +1 -0
- data/config/initializers/state_machine.rb +4 -0
- data/config/locales/devise.en.yml +57 -0
- data/config/routes.rb +26 -0
- data/db/migrate/20120217213920_create_miniblog_posts.rb +17 -0
- data/db/migrate/20120219071614_create_miniblog_assets.rb +10 -0
- data/lib/generators/miniblog/views_generator.rb +11 -0
- data/lib/miniblog.rb +18 -0
- data/lib/miniblog/devise/failure_app.rb +9 -0
- data/lib/miniblog/engine.rb +9 -0
- data/lib/miniblog/rspec.rb +1 -0
- data/lib/miniblog/rspec/miniblog_shared_examples.rb +77 -0
- data/lib/miniblog/version.rb +3 -0
- data/miniblog.gemspec +40 -0
- data/script/cucumber +10 -0
- data/script/rails +8 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +16 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/models/user.rb +3 -0
- data/spec/dummy/app/views/home/show.html.slim +4 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +28 -0
- data/spec/dummy/config/boot.rb +4 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +82 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/carrierwave.rb +18 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/miniblog.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/db/schema.rb +50 -0
- data/spec/dummy/db/seed.rb +6 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/lib/tasks/cucumber.rake +65 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/features/miniblog_spec.rb +5 -0
- data/spec/generators/miniblog/views_generator_spec.rb +16 -0
- data/spec/models/post_spec.rb +163 -0
- data/spec/spec_helper.rb +58 -0
- data/vendor/assets/javascripts/markdown.js +1470 -0
- data/vendor/assets/javascripts/uploader/jquery.html5uploader.js +148 -0
- metadata +464 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 126730742ab39e8cf2d51ba95ce24582a4561201
|
4
|
+
data.tar.gz: 6d53653058c0cf6d21cdb75bb3c185857aaa12ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 60b5e143ae016cc4e6d2b0833d0c8e75a322ebfe89de18661de17b42a6be9051d61b1fb13eb70d71e3bdb50cc52fb1f628b5d5df44b8eeac3792e12ea9c5b18c
|
7
|
+
data.tar.gz: cba34bbf7f90417680cc5bf87b694baff27c62089cf87600c7992ae9c4b9517b2aa01b750f0b446567cdf6904a865e2a5fa33ea3ce584813534a06ffa7965b1c
|
data/.autotest
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.simplecov
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# use RCov formatter for metric_fu: http://bit.ly/wQbrxB
|
2
|
+
require 'simplecov-rcov-text'
|
3
|
+
|
4
|
+
class SimpleCov::Formatter::MergedFormatter
|
5
|
+
def format(result)
|
6
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
7
|
+
SimpleCov::Formatter::RcovTextFormatter.new.format(result)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
11
|
+
|
12
|
+
SimpleCov.start 'rails' do
|
13
|
+
end
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1.0
|
4
|
+
- 2.2.0
|
5
|
+
|
6
|
+
gemfile:
|
7
|
+
- Gemfile
|
8
|
+
- Gemfile.4.1
|
9
|
+
|
10
|
+
before_script:
|
11
|
+
- "export DISPLAY=:99.0"
|
12
|
+
- "sh -e /etc/init.d/xvfb start"
|
13
|
+
- "bundle exec rake db:migrate > /dev/null 2>&1"
|
14
|
+
- "RAILS_ENV=test bundle exec rake db:migrate > /dev/null 2>&1"
|
15
|
+
|
16
|
+
before_install:
|
17
|
+
- "gem install bundler"
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem "jquery-rails"
|
6
|
+
gem 'nokogiri', '= 1.6.3'
|
7
|
+
|
8
|
+
gem "rails", "~> 4.2.0"
|
9
|
+
gem 'bootstrap-sass'
|
10
|
+
|
11
|
+
group :assets do
|
12
|
+
gem 'coffee-rails', '~> 4.0.0'
|
13
|
+
gem 'sass-rails' , '~> 4.0.0'
|
14
|
+
gem 'uglifier' , '~> 2.5.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :development, :test do
|
18
|
+
gem 'rake' # needed for Travis CI: http://bit.ly/xEgH8j
|
19
|
+
gem 'launchy'
|
20
|
+
end
|
data/Gemfile.4.1
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
|
5
|
+
gem "jquery-rails"
|
6
|
+
gem 'nokogiri', '= 1.6.3'
|
7
|
+
|
8
|
+
gem "rails", "~> 4.1.0"
|
9
|
+
|
10
|
+
group :assets do
|
11
|
+
gem 'coffee-rails', '~> 4.0.0'
|
12
|
+
gem 'sass-rails' , '~> 4.0.0'
|
13
|
+
gem 'uglifier' , '~> 2.5.0'
|
14
|
+
end
|
15
|
+
|
16
|
+
group :development, :test do
|
17
|
+
gem 'rake' # needed for Travis CI: http://bit.ly/xEgH8j
|
18
|
+
gem 'launchy'
|
19
|
+
end
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Crowd Interactive
|
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.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# miniblog
|
2
|
+
|
3
|
+
CI:
|
4
|
+
[![Build Status](https://travis-ci.org/dabit/miniblog.svg?branch=master)](https://travis-ci.org/dabit/miniblog)
|
5
|
+
|
6
|
+
Code Climate:
|
7
|
+
[![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/dabit/miniblog)
|
8
|
+
|
9
|
+
Generic Blog engine, currently in use by [david.padilla.cc](http://david.padilla.cc).
|
10
|
+
Spiritual successor to [crowdblog](https://github.com/crowdint/crowdblog).
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Gemfile
|
15
|
+
|
16
|
+
gem 'miniblog'
|
17
|
+
|
18
|
+
Bundle
|
19
|
+
|
20
|
+
bundle install
|
21
|
+
|
22
|
+
Copy migrations
|
23
|
+
|
24
|
+
rake miniblog:install:migrations
|
25
|
+
|
26
|
+
Run them
|
27
|
+
|
28
|
+
rake db:migrate
|
29
|
+
|
30
|
+
Mount
|
31
|
+
|
32
|
+
#
|
33
|
+
# routes.rb
|
34
|
+
#
|
35
|
+
|
36
|
+
mount Miniblog::Engine => '/blog'
|
37
|
+
|
38
|
+
Enjoy.
|
39
|
+
|
40
|
+
Your Rails App should implement the "client facing" pages. Read posts from the
|
41
|
+
miniblog::Post model.
|
42
|
+
|
43
|
+
## Testing: Use with caution
|
44
|
+
|
45
|
+
If you are using it as a 'vanilla' installation, that is, without a lot of
|
46
|
+
customizations, you can use some specs that are included with the gem to make
|
47
|
+
sure your blog behaves properly.
|
48
|
+
|
49
|
+
Add this on your spec_helper, right after you require `rspec/rails`:
|
50
|
+
|
51
|
+
require 'miniblog/rspec'
|
52
|
+
require 'database_cleaner'
|
53
|
+
|
54
|
+
Your are going to need DatabaseCleaner to use truncation strategies for your
|
55
|
+
data. Add these lines to spec_helper.rb:
|
56
|
+
|
57
|
+
Rspec.configure do |config|
|
58
|
+
|
59
|
+
config.use_transactional_fixtures = false
|
60
|
+
|
61
|
+
config.before(:suite) do
|
62
|
+
DatabaseCleaner.strategy = :truncation
|
63
|
+
DatabaseCleaner.clean_with(:truncation)
|
64
|
+
end
|
65
|
+
|
66
|
+
config.before(:each) do
|
67
|
+
DatabaseCleaner.start
|
68
|
+
end
|
69
|
+
|
70
|
+
config.after(:each) do
|
71
|
+
DatabaseCleaner.clean
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
Now, create a miniblog spec:
|
76
|
+
|
77
|
+
#
|
78
|
+
# spec/integration/miniblog_spec.rb
|
79
|
+
#
|
80
|
+
require 'spec_helper'
|
81
|
+
|
82
|
+
describe "miniblog" do
|
83
|
+
it_behaves_like "a miniblog"
|
84
|
+
end
|
85
|
+
|
86
|
+
And run your specs. It should test miniblog properly.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'Miniblog'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
24
|
+
load 'rails/tasks/engine.rake'
|
25
|
+
|
26
|
+
Bundler::GemHelper.install_tasks
|
27
|
+
|
28
|
+
require 'rspec/core/rake_task'
|
29
|
+
RSpec::Core::RakeTask.new(:default)
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
@import "bootstrap";
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/* Edit post */
|
2
|
+
#post-preview {
|
3
|
+
height: 420px;
|
4
|
+
overflow-y: scroll;
|
5
|
+
background: #EBEBEB;
|
6
|
+
|
7
|
+
.inner {
|
8
|
+
padding: 5px;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
form .clear {
|
13
|
+
clear: both;
|
14
|
+
}
|
15
|
+
|
16
|
+
.new-link {
|
17
|
+
padding: 5px 0 5px 0;
|
18
|
+
}
|
19
|
+
|
20
|
+
#uploader {
|
21
|
+
border: 3px #ebebeb dashed;
|
22
|
+
|
23
|
+
.inner {
|
24
|
+
padding: 20px;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
#uploader:hover {
|
29
|
+
background-color: #ebebeb;
|
30
|
+
}
|
31
|
+
|
32
|
+
.form-box {
|
33
|
+
margin-top: 15px;
|
34
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Miniblog
|
2
|
+
module Admin
|
3
|
+
class AssetsController < Miniblog::Admin::BaseController
|
4
|
+
# TODO: Skipping filters is the worst solution ever to this problem
|
5
|
+
# Someone should fix the uploadify.js thing
|
6
|
+
skip_before_filter :verify_authenticity_token, :only => :create
|
7
|
+
skip_before_filter :authorize!
|
8
|
+
|
9
|
+
def create
|
10
|
+
@post = Post.find(params[:post_id])
|
11
|
+
asset = @post.assets.build
|
12
|
+
asset.attachment = params['attachment']
|
13
|
+
asset.save!
|
14
|
+
|
15
|
+
render json: asset
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module Miniblog
|
2
|
+
module Admin
|
3
|
+
class PostsController < Miniblog::Admin::BaseController
|
4
|
+
before_filter :load_post, :only => [ :edit, :update, :destroy ]
|
5
|
+
|
6
|
+
def new
|
7
|
+
@post = Post.new
|
8
|
+
@post.state = :drafted
|
9
|
+
@post.author = current_user
|
10
|
+
end
|
11
|
+
|
12
|
+
def index
|
13
|
+
@state = params[:state]
|
14
|
+
@posts = Post.for_admin_index
|
15
|
+
@posts = @posts.with_state(@state) if @state
|
16
|
+
end
|
17
|
+
|
18
|
+
def create
|
19
|
+
@post = Post.new(post_params)
|
20
|
+
@post.state = :drafted
|
21
|
+
@post.author = current_user
|
22
|
+
@post.regenerate_permalink
|
23
|
+
if @post.save
|
24
|
+
redirect_to miniblog.edit_admin_post_path(@post), notice: "Post created succesfully"
|
25
|
+
else
|
26
|
+
render action: :new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy
|
31
|
+
@post.destroy
|
32
|
+
redirect_to miniblog.admin_posts_path
|
33
|
+
end
|
34
|
+
|
35
|
+
def show
|
36
|
+
@post = Post.includes(:assets).find(params[:id])
|
37
|
+
end
|
38
|
+
|
39
|
+
def edit
|
40
|
+
end
|
41
|
+
|
42
|
+
def update
|
43
|
+
if @post.update_attributes(post_params)
|
44
|
+
if @post.allowed_to_update_permalink?
|
45
|
+
@post.regenerate_permalink
|
46
|
+
@post.save!
|
47
|
+
end
|
48
|
+
flash[:notice] = "Post updated succesfully"
|
49
|
+
end
|
50
|
+
render action: :edit
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
def load_post
|
55
|
+
@post = Post.scoped_for(current_user).find(params[:id])
|
56
|
+
end
|
57
|
+
|
58
|
+
def post_params
|
59
|
+
params.require(:post).permit(:title, :body, :updated_by, :ready_for_review, :transition)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|