blabs 0.4.4

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.
Files changed (77) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +15 -0
  3. data/app/assets/images/uploadify-cancel.png +0 -0
  4. data/app/assets/images/uploadify.swf +0 -0
  5. data/app/assets/javascripts/blabs.js +79 -0
  6. data/app/assets/javascripts/jquery.uploadify.min.js +16 -0
  7. data/app/assets/stylesheets/blabs/blog.sass +6 -0
  8. data/app/assets/stylesheets/uploadify.css.scss +92 -0
  9. data/app/controllers/blabs/blog_posts_controller.rb +131 -0
  10. data/app/controllers/blabs/images_controller.rb +35 -0
  11. data/app/controllers/blabs/published_blog_posts_controller.rb +30 -0
  12. data/app/controllers/blabs_controller.rb +31 -0
  13. data/app/helpers/blabs/blog_posts_helper.rb +114 -0
  14. data/app/models/blabs/blog_post.rb +70 -0
  15. data/app/models/blabs/image.rb +4 -0
  16. data/app/models/blabs/tag.rb +9 -0
  17. data/app/models/blabs/tagging.rb +9 -0
  18. data/app/uploaders/image_uploader.rb +65 -0
  19. data/app/views/blabs/blog_posts/_form.html.haml +54 -0
  20. data/app/views/blabs/blog_posts/_image.html.haml +5 -0
  21. data/app/views/blabs/blog_posts/_image_panel.html.haml +32 -0
  22. data/app/views/blabs/blog_posts/edit.html.haml +7 -0
  23. data/app/views/blabs/blog_posts/feed.atom.builder +15 -0
  24. data/app/views/blabs/blog_posts/index.html.haml +27 -0
  25. data/app/views/blabs/blog_posts/new.html.haml +7 -0
  26. data/app/views/blabs/blog_posts/show.html.haml +16 -0
  27. data/app/views/layouts/blabs.html.erb +21 -0
  28. data/config/routes.rb +16 -0
  29. data/db/migrate/20130802113537_create_blabs_tables.rb +23 -0
  30. data/db/migrate/20130909092406_add_extract_to_blog_posts.rb +5 -0
  31. data/db/migrate/20131209144117_create_tags.rb +16 -0
  32. data/lib/blabs.rb +53 -0
  33. data/lib/blabs/engine.rb +13 -0
  34. data/lib/blabs/version.rb +3 -0
  35. data/lib/generators/blabs_generator.rb +8 -0
  36. data/lib/tasks/blabs_tasks.rake +4 -0
  37. data/spec/controllers/blabs/blog_posts_controller_spec.rb +50 -0
  38. data/spec/controllers/blabs/published_blog_posts_controller_spec.rb +32 -0
  39. data/spec/dummy/README.rdoc +28 -0
  40. data/spec/dummy/Rakefile +6 -0
  41. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  42. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  43. data/spec/dummy/app/controllers/application_controller.rb +15 -0
  44. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  45. data/spec/dummy/app/models/account.rb +2 -0
  46. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  47. data/spec/dummy/bin/bundle +3 -0
  48. data/spec/dummy/bin/rails +4 -0
  49. data/spec/dummy/bin/rake +4 -0
  50. data/spec/dummy/config.ru +4 -0
  51. data/spec/dummy/config/application.rb +23 -0
  52. data/spec/dummy/config/boot.rb +5 -0
  53. data/spec/dummy/config/database.yml +25 -0
  54. data/spec/dummy/config/environment.rb +5 -0
  55. data/spec/dummy/config/environments/development.rb +29 -0
  56. data/spec/dummy/config/environments/production.rb +80 -0
  57. data/spec/dummy/config/environments/test.rb +36 -0
  58. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  59. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/spec/dummy/config/initializers/inflections.rb +16 -0
  61. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  62. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  63. data/spec/dummy/config/initializers/session_store.rb +3 -0
  64. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  65. data/spec/dummy/config/locales/en.yml +23 -0
  66. data/spec/dummy/config/routes.rb +56 -0
  67. data/spec/dummy/db/migrate/20130808145755_create_accounts.rb +9 -0
  68. data/spec/dummy/db/schema.rb +60 -0
  69. data/spec/dummy/public/404.html +58 -0
  70. data/spec/dummy/public/422.html +58 -0
  71. data/spec/dummy/public/500.html +57 -0
  72. data/spec/dummy/public/favicon.ico +0 -0
  73. data/spec/helpers/blabs/blog_posts_helper_spec.rb +50 -0
  74. data/spec/lib/blabs_spec.rb +8 -0
  75. data/spec/models/blabs/blog_post_spec.rb +76 -0
  76. data/spec/spec_helper.rb +19 -0
  77. metadata +356 -0
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title><%= yield(:title) %></title>
5
+ <%= stylesheet_link_tag "uploadify.css", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "blabs", "jquery.uploadify.min", "data-turbolinks-track" => true %>
7
+
8
+ <!-- bootstrap 3.0.0-rc1 -->
9
+ <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/css/bootstrap.min.css">
10
+ <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0-rc1/js/bootstrap.min.js"></script>
11
+ <%= csrf_meta_tags %>
12
+ </head>
13
+ <body>
14
+
15
+ <div class="container">
16
+ <%= yield %>
17
+ </div>
18
+
19
+ <%= yield :scripts %>
20
+ </body>
21
+ </html>
@@ -0,0 +1,16 @@
1
+ Rails.application.routes.draw do
2
+ get '/blog/feed' => 'blabs/blog_posts#feed',
3
+ as: :feed,
4
+ defaults: { format: 'atom' }
5
+
6
+
7
+ get "/blog", to: "blabs/blog_posts#index", as: :blog
8
+ get "/blog/:id", to: "blabs/blog_posts#show"
9
+
10
+ namespace :blabs do
11
+ resources :blog_posts
12
+ resource :published_blog_posts
13
+ resources :images, defaults: {format: 'js'}
14
+ end
15
+
16
+ end
@@ -0,0 +1,23 @@
1
+ class CreateBlabsTables < ActiveRecord::Migration
2
+ def change
3
+ create_table :blabs_blog_posts do |t|
4
+ t.string :title, null: false
5
+ t.string :path, null: false
6
+ t.string :meta_title
7
+ t.text :body, null: false
8
+ t.boolean :published, default: false
9
+ t.datetime :published_at
10
+ t.string :author
11
+ t.string :author_twitter_username
12
+ t.text :extra_attributes
13
+ t.integer :blabs_user_id
14
+ t.timestamps
15
+ end
16
+
17
+ create_table :blabs_images do |t|
18
+ t.string :image
19
+
20
+ t.timestamps
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ class AddExtractToBlogPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :blabs_blog_posts, :extract, :text
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ class CreateTags < ActiveRecord::Migration
2
+ def change
3
+ create_table :blabs_tags do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+
9
+ create_table :blabs_taggings do |t|
10
+ t.belongs_to :blabs_tag, index: true
11
+ t.belongs_to :blabs_blog_post, index: true
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,53 @@
1
+ require "blabs/engine"
2
+ require 'redcarpet'
3
+ require 'carrierwave'
4
+ require 'mini_magick'
5
+ require 'truncate_html'
6
+
7
+ module Blabs
8
+ mattr_accessor :blog_layout, :admin_method, :current_user_method,
9
+ :fog_credentials, :fog_directory, :extra_attributes, :twitter_site_username,
10
+ :post_image_url_attribute, :blog_title
11
+
12
+
13
+ def self.configure
14
+ yield(self)
15
+ end
16
+
17
+ def self.blog_title
18
+ @@blog_title
19
+ end
20
+
21
+ def self.blog_layout
22
+ @@blog_layout || "application"
23
+ end
24
+
25
+ def self.admin_method
26
+ @@admin_method || :admin_required
27
+ end
28
+
29
+ def self.current_user_method
30
+ @@current_user_method || :current_user
31
+ end
32
+
33
+ def self.fog_credentials
34
+ @@fog_credentials
35
+ end
36
+
37
+ def self.fog_directory
38
+ @@fog_directory
39
+ end
40
+
41
+ def self.extra_attributes
42
+ @@extra_attributes || []
43
+ end
44
+
45
+ def self.twitter_site_username
46
+ @@twitter_site_username ||= "@thechrisoshow"
47
+ "@#{@@twitter_site_username}".squeeze("@")
48
+ end
49
+
50
+ def self.post_image_url_attribute
51
+ @@post_image_url_attribute ||= nil
52
+ end
53
+ end
@@ -0,0 +1,13 @@
1
+ module Blabs
2
+ class Engine < ::Rails::Engine
3
+ config.generators do |g|
4
+ g.test_framework :rspec
5
+ g.assets false
6
+ g.helper false
7
+ end
8
+
9
+ initializer "blabs.assets.precompile" do |app|
10
+ app.config.assets.precompile += %w(uploadify.css blabs.js jquery.uploadify.min.js uploadify.swf)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module Blabs
2
+ VERSION = "0.4.4"
3
+ end
@@ -0,0 +1,8 @@
1
+ class BlabsGenerator < Rails::Generators::Base
2
+ source_root File.expand_path("../../../app/assets/stylesheets/blabs", __FILE__)
3
+
4
+ desc "This generator copies over a scaffold style into app/assets/stylesheets"
5
+ def copy_basic_style
6
+ copy_file("blog.sass", "app/assets/stylesheets/blog.sass")
7
+ end
8
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :blabs do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blabs::BlogPostsController do
4
+
5
+ before(:each) do
6
+ controller.stub(:blabs_admin_required).and_return(true)
7
+ end
8
+
9
+ describe "#show" do
10
+ it "raises a routing error if post not found" do
11
+ expect { get :show, id: "bananas" }.to raise_error(ActionController::RoutingError)
12
+ end
13
+ end
14
+
15
+ describe "#create" do
16
+ it "preview doesn't save" do
17
+ post :create, blabs_blog_post: {title: "title", body: "body", author: "author"}, preview: true
18
+ blog_post = assigns[:blog_post]
19
+ expect(blog_post).to be_valid
20
+ expect(blog_post.id).to be_nil
21
+ end
22
+
23
+ it "publish saves as published" do
24
+ post :create, blabs_blog_post: {title: "title", body: "body", author: "author"}, publish: true
25
+ expect(assigns[:blog_post]).to be_published
26
+ end
27
+
28
+ it "saves extra attributes as defined in the config" do
29
+ Blabs.extra_attributes = [:fruit]
30
+ post :create, blabs_blog_post: {title: "title", body: "body", author: "author", extra_attributes: {fruit: "Banana"}}
31
+ expect(assigns[:blog_post].extra_attributes[:fruit]).to eq("Banana")
32
+ end
33
+ end
34
+
35
+ describe "update" do
36
+ it "unpublishes if saving without publish" do
37
+ blog_post = create_blog_post(published: true)
38
+ patch :update, id: blog_post.path, blabs_blog_post: {title: "bananas"}, publish: false
39
+ expect(assigns[:blog_post]).to_not be_published
40
+ end
41
+
42
+ it "doesn't update published at if already published" do
43
+ initial_published_at = Date.today - 1.week
44
+ blog_post = create_blog_post(published: true, published_at: initial_published_at)
45
+ patch :update, id: blog_post.path, blabs_blog_post: {title: "bananas"}, publish: true
46
+ expect(assigns[:blog_post].published_at).to eq(initial_published_at)
47
+
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe Blabs::PublishedBlogPostsController do
4
+
5
+ before(:each) do
6
+ controller.stub(:is_admin).and_return(true)
7
+ end
8
+
9
+ after(:each) do
10
+ Timecop.return
11
+ end
12
+
13
+ describe "#create" do
14
+ it "makes a blog post published" do
15
+ Timecop.freeze
16
+ blog_post = create_blog_post(published: false, published_at: nil)
17
+ post :create, id: blog_post.to_param
18
+ expect(assigns[:blog_post]).to be_published
19
+ expect(assigns[:blog_post].published_at).to eq(Time.now)
20
+ end
21
+ end
22
+
23
+ describe "#destroy" do
24
+ it "unpublishes a blog post" do
25
+ Timecop.freeze
26
+ blog_post = create_blog_post(published: true, published_at: Time.now - 1.week)
27
+ delete :destroy, id: blog_post.to_param
28
+ expect(assigns[:blog_post]).to_not be_published
29
+ expect(assigns[:blog_post].published_at).to be_nil
30
+ end
31
+ end
32
+ 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>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -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,13 @@
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_tree .
13
+ */
@@ -0,0 +1,15 @@
1
+ require 'ostruct'
2
+
3
+ class ApplicationController < ActionController::Base
4
+ # Prevent CSRF attacks by raising an exception.
5
+ # For APIs, you may want to use :null_session instead.
6
+ protect_from_forgery with: :exception
7
+
8
+ def admin_required
9
+ true
10
+ end
11
+
12
+ def current_user
13
+ OpenStruct.new(id: 1, email: "chris@bananas.com")
14
+ end
15
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ class Account < ActiveRecord::Base
2
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "blog", "uploadify.css", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "jquery.uploadify.min", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "blabs"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000