crowdblog 0.0.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.
Files changed (107) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +2 -0
  3. data/.rvmrc +1 -0
  4. data/.simplecov +13 -0
  5. data/Gemfile +35 -0
  6. data/Gemfile.lock +291 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.rdoc +3 -0
  9. data/Rakefile +32 -0
  10. data/app/assets/images/crowdblog/.gitkeep +0 -0
  11. data/app/assets/images/crowdblog/logo.png +0 -0
  12. data/app/assets/javascripts/crowdblog/models/post.js.coffee +11 -0
  13. data/app/assets/javascripts/crowdblog/posts_main.js.coffee +42 -0
  14. data/app/assets/javascripts/crowdblog/templates/posts/attachment.jst.eco +1 -0
  15. data/app/assets/javascripts/crowdblog/templates/posts/edit.jst.eco +38 -0
  16. data/app/assets/javascripts/crowdblog/templates/posts/index.jst.eco +17 -0
  17. data/app/assets/javascripts/crowdblog/templates/posts/post.jst.eco +27 -0
  18. data/app/assets/javascripts/crowdblog/views/posts/attachment_view.js.coffee +8 -0
  19. data/app/assets/javascripts/crowdblog/views/posts/edit_post_view.js.coffee +41 -0
  20. data/app/assets/javascripts/crowdblog/views/posts/index.js.coffee +28 -0
  21. data/app/assets/javascripts/crowdblog/views/posts/post_view.js.coffee +40 -0
  22. data/app/assets/javascripts/crowdblog/xhr_fix.js.coffee +4 -0
  23. data/app/assets/javascripts/crowdblog.js +16 -0
  24. data/app/assets/stylesheets/crowdblog/posts.css.scss +3 -0
  25. data/app/assets/stylesheets/crowdblog.css +7 -0
  26. data/app/controllers/crowdblog/application_controller.rb +16 -0
  27. data/app/controllers/crowdblog/assets_controller.rb +14 -0
  28. data/app/controllers/crowdblog/authors_controller.rb +9 -0
  29. data/app/controllers/crowdblog/posts_controller.rb +48 -0
  30. data/app/controllers/crowdblog/sessions_controller.rb +25 -0
  31. data/app/controllers/crowdblog/users/omniauth_callbacks_controller.rb +21 -0
  32. data/app/helpers/crowdblog/application_helper.rb +4 -0
  33. data/app/models/crowdblog/asset.rb +8 -0
  34. data/app/models/crowdblog/post.rb +121 -0
  35. data/app/models/crowdblog/user.rb +32 -0
  36. data/app/sweepers/post_sweeper.rb +5 -0
  37. data/app/uploaders/attachment_uploader.rb +48 -0
  38. data/app/views/crowdblog/authors/index.html.slim +18 -0
  39. data/app/views/crowdblog/posts/index.html.slim +13 -0
  40. data/app/views/layouts/crowdblog/application.html.slim +25 -0
  41. data/config/cucumber.yml +8 -0
  42. data/config/routes.rb +14 -0
  43. data/crowdblog.gemspec +46 -0
  44. data/db/migrate/20120215232711_create_users.rb +10 -0
  45. data/db/migrate/20120216154516_add_devise_to_users.rb +56 -0
  46. data/db/migrate/20120217213920_create_posts.rb +13 -0
  47. data/db/migrate/20120219014520_add_author_to_posts.rb +6 -0
  48. data/db/migrate/20120219040607_add_state_to_post.rb +7 -0
  49. data/db/migrate/20120219071614_create_assets.rb +10 -0
  50. data/db/migrate/20120219234253_add_alias_to_users.rb +6 -0
  51. data/db/migrate/20120220033923_create_vestal_versions.rb +28 -0
  52. data/features/posts/manage_posts.feature +46 -0
  53. data/features/step_definitions/index_steps.rb +16 -0
  54. data/features/step_definitions/interaction_steps.rb +26 -0
  55. data/features/step_definitions/posts_steps.rb +35 -0
  56. data/features/step_definitions/session_steps.rb +15 -0
  57. data/features/support/env.rb +69 -0
  58. data/lib/crowdblog/engine.rb +5 -0
  59. data/lib/crowdblog/version.rb +3 -0
  60. data/lib/crowdblog.rb +4 -0
  61. data/lib/tasks/crowdblog_tasks.rake +4 -0
  62. data/script/build +29 -0
  63. data/script/cucumber +10 -0
  64. data/script/rails +8 -0
  65. data/spec/dummy/.rvmrc +1 -0
  66. data/spec/dummy/README.rdoc +261 -0
  67. data/spec/dummy/Rakefile +7 -0
  68. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  69. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  70. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  71. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  72. data/spec/dummy/app/mailers/.gitkeep +0 -0
  73. data/spec/dummy/app/models/.gitkeep +0 -0
  74. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  75. data/spec/dummy/config/application.rb +62 -0
  76. data/spec/dummy/config/boot.rb +10 -0
  77. data/spec/dummy/config/database.yml +25 -0
  78. data/spec/dummy/config/environment.rb +5 -0
  79. data/spec/dummy/config/environments/development.rb +37 -0
  80. data/spec/dummy/config/environments/production.rb +67 -0
  81. data/spec/dummy/config/environments/test.rb +37 -0
  82. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/spec/dummy/config/initializers/carrierwave.rb +18 -0
  84. data/spec/dummy/config/initializers/devise.rb +230 -0
  85. data/spec/dummy/config/initializers/inflections.rb +15 -0
  86. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  87. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  88. data/spec/dummy/config/initializers/session_store.rb +8 -0
  89. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  90. data/spec/dummy/config/locales/en.yml +5 -0
  91. data/spec/dummy/config/routes.rb +6 -0
  92. data/spec/dummy/config.ru +4 -0
  93. data/spec/dummy/db/schema.rb +76 -0
  94. data/spec/dummy/lib/assets/.gitkeep +0 -0
  95. data/spec/dummy/lib/tasks/cucumber.rake +65 -0
  96. data/spec/dummy/log/.gitkeep +0 -0
  97. data/spec/dummy/public/404.html +26 -0
  98. data/spec/dummy/public/422.html +26 -0
  99. data/spec/dummy/public/500.html +25 -0
  100. data/spec/dummy/public/favicon.ico +0 -0
  101. data/spec/dummy/script/rails +6 -0
  102. data/spec/helpers/application_helper_spec.rb +4 -0
  103. data/spec/models/post_spec.rb +94 -0
  104. data/spec/spec_helper.rb +39 -0
  105. data/vendor/assets/javascripts/jquery.uploadify.js +296 -0
  106. data/vendor/assets/javascripts/swfobject.js +4 -0
  107. metadata +428 -0
@@ -0,0 +1,4 @@
1
+ $.ajaxSetup
2
+ beforeSend: (xhr) ->
3
+ xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content'))
4
+
@@ -0,0 +1,16 @@
1
+ /*
2
+ *= require 'jquery'
3
+ *= require 'jquery_ujs'
4
+ *= require 'underscore'
5
+ *= require 'backbone'
6
+ *= require 'swfobject'
7
+ *= require 'jquery.uploadify'
8
+ *= require_self
9
+ *= require_tree ./crowdblog/models
10
+ *= require_tree ./crowdblog/views
11
+ *= require_tree ./crowdblog/templates
12
+ *= require ./crowdblog/posts_main
13
+ *= require ./crowdblog/xhr_fix
14
+ */
15
+
16
+ window.PostsApp = {};
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the admin/posts controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,7 @@
1
+ /*
2
+ *
3
+ *= require twitter/bootstrap
4
+ *= require_self
5
+ *= require_tree ./crowdblog
6
+ *
7
+ */
@@ -0,0 +1,16 @@
1
+ module Crowdblog
2
+ class ApplicationController < ActionController::Base
3
+ before_filter :authenticate!
4
+
5
+ def authenticate!
6
+ unless user_signed_in?
7
+ current_user = User.find_by_email('foo@crowdint.com') || User.create!(email: 'foo@crowdint.com', is_publisher: true)
8
+ sign_in current_user
9
+ end
10
+
11
+ #TODO: fix OAuth
12
+ #redirect_to user_omniauth_authorize_path(:google_apps) unless current_user
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module Crowdblog
2
+ class AssetsController < ApplicationController
3
+
4
+ def create
5
+ @post = Post.find(params[:post_id])
6
+ asset = @post.assets.build
7
+ asset.attachment = params['Filedata']
8
+ asset.save!
9
+
10
+ render json: asset
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ module Crowdblog
2
+ class AuthorsController < ApplicationController
3
+
4
+ def index
5
+ @authors = User.includes(:authored_posts).sort {|a,b| b.authored_posts.count <=> a.authored_posts.count}
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,48 @@
1
+ module Crowdblog
2
+ class PostsController < ApplicationController
3
+ respond_to :html, :json
4
+ cache_sweeper :post_sweeper
5
+
6
+ def index
7
+ @posts = Post.scoped_for(current_user).all_posts_json
8
+ respond_to do |format|
9
+ format.json { render json: @posts }
10
+ format.html
11
+ end
12
+ end
13
+
14
+ def create
15
+ @post = Post.new(params[:post])
16
+ @post.author = current_user
17
+ @post.regenerate_permalink
18
+ @post.save
19
+ respond_with @post
20
+ end
21
+
22
+ def destroy
23
+ @post = Post.scoped_for(current_user).find(params[:id])
24
+ @post.destroy
25
+ respond_with @post
26
+ end
27
+
28
+ def show
29
+ @post = Post.includes(:assets).find(params[:id])
30
+ respond_to do |format|
31
+ format.json { render json: @post.to_json(include: :assets) }
32
+ end
33
+ end
34
+
35
+ def update
36
+ @post = Post.scoped_for(current_user).find(params[:id])
37
+ @post.update_attributes(params[:post], updated_by: current_user)
38
+ if @post.allowed_to_update_permalink?
39
+ @post.regenerate_permalink
40
+ @post.save!
41
+ end
42
+
43
+ @post.publish_if_allowed(params[:transition], current_user) if params[:transition]
44
+
45
+ respond_with @post
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ module Crowdblog
2
+ class SessionsController < ApplicationController
3
+
4
+ def authenticate_user
5
+ auth_hash = request.env['omniauth.auth']
6
+
7
+ if allowed?
8
+ Rails.logger.info auth_hash.info
9
+ email = auth_hash.info['email']
10
+ user = User.find_by_email(email)
11
+ user ||= User.create!(email: email, name: auth_hash.info['name'])
12
+ sign_in user
13
+
14
+ redirect_to root_url
15
+ else
16
+ render :text => '401 Unauthorized', :status => 401
17
+ end
18
+ end
19
+
20
+ def allowed?
21
+ true
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ module Crowdblog
2
+ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
3
+
4
+ def google_apps
5
+ auth_hash = request.env['omniauth.auth']
6
+ email = auth_hash.info['email']
7
+ Rails.logger.info auth_hash
8
+
9
+ user = User.find_by_email(email)
10
+ user ||= User.create!(email: email, name: auth_hash.info['name'])
11
+
12
+ if user.persisted?
13
+ sign_in_and_redirect user
14
+ end
15
+ end
16
+
17
+ #def google_apps
18
+ #end
19
+
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ module Crowdblog
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module Crowdblog
2
+ class Asset < ActiveRecord::Base
3
+ self.table_name = :assets
4
+ belongs_to :post
5
+
6
+ mount_uploader :attachment, AttachmentUploader
7
+ end
8
+ end
@@ -0,0 +1,121 @@
1
+ module Crowdblog
2
+ class Post < ActiveRecord::Base
3
+ self.table_name = :posts
4
+ versioned
5
+
6
+ belongs_to :author, class_name: 'User'
7
+ belongs_to :publisher, class_name: 'User'
8
+ has_many :assets
9
+
10
+ delegate :name, to: :author, prefix: true
11
+ delegate :email, to: :author, prefix: true
12
+ delegate :gravatar_url, to: :author
13
+
14
+ delegate :year, to: :published_at
15
+
16
+ validates :title, length: { minimum: 5, maximum: 90 }
17
+
18
+ attr_accessible :title, :body, :updated_by
19
+
20
+ LEGACY_TITLE_REGEXP = /(\d+-\d+-\d+)-(.*)/
21
+
22
+ state_machine initial: :drafted do
23
+ state :drafted
24
+ state :published
25
+
26
+ before_transition on: :publish do |post, transition|
27
+ #post.update_attribute(:published_at, Time.now)
28
+ post.published_at ||= Time.now
29
+ end
30
+
31
+ event :publish do
32
+ transition drafted: :published
33
+ end
34
+
35
+ event :draft do
36
+ transition published: :drafted
37
+ end
38
+ end
39
+
40
+ def self.all_posts_json
41
+ order('published_at desc, created_at desc').to_json only: [:id, :title, :state, :published_at],
42
+ methods: [:author_email, :published?]
43
+ end
44
+
45
+ def self.scoped_for(user)
46
+ user.is_publisher? ? Post : user.authored_posts
47
+ end
48
+
49
+
50
+ def self.all_for_feed
51
+ Post.published_and_ordered.limit(15)
52
+ end
53
+
54
+ def self.for_index
55
+ Post.published_and_ordered.limit(3)
56
+ end
57
+
58
+ def self.for_history
59
+ Post.published_and_ordered.limit(13)
60
+ end
61
+
62
+ def self.published_and_ordered
63
+ Post.where(state: 'published').order('published_at DESC').includes(:author)
64
+ end
65
+
66
+ def regenerate_permalink
67
+ self.permalink = title.parameterize
68
+ end
69
+
70
+ def allowed_to_update_permalink?
71
+ !self.published?
72
+ end
73
+
74
+ def formatted_published_date
75
+ published_at.strftime("%b %d, %Y")
76
+ end
77
+
78
+ def month
79
+ "%02d" % published_at.month
80
+ end
81
+
82
+ def day
83
+ "%02d" % published_at.day
84
+ end
85
+
86
+ def legacy(string, email)
87
+ results = string.match(LEGACY_TITLE_REGEXP)
88
+ self.published_at = "#{results[1]}"
89
+ user = User.find_by_email(email) || User.create!(email: email)
90
+ self.author = user
91
+ self.save
92
+ self.publish
93
+ self.update_attribute(:permalink, results[2])
94
+ end
95
+
96
+ #
97
+ # Use this methods to generate the post url
98
+ # always use with the splat
99
+ # operator
100
+ #
101
+ # Example:
102
+ # post_url(*post.url_params)
103
+ #
104
+ def url_params
105
+ [self.year, self.month, self.day, self.permalink, 'html']
106
+ end
107
+
108
+ def html_body
109
+ @@renderer ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML,
110
+ :autolink => true, :space_after_headers => true)
111
+ @@renderer.render(self.body).html_safe
112
+ end
113
+
114
+ def publish_if_allowed(transition, user)
115
+ if user.is_publisher?
116
+ self.publisher = user
117
+ self.send(transition)
118
+ end
119
+ end
120
+ end
121
+ end
@@ -0,0 +1,32 @@
1
+ module Crowdblog
2
+ class User < ActiveRecord::Base
3
+ self.table_name = :users
4
+ include Gravtastic
5
+
6
+ has_many :authored_posts, inverse_of: :author, foreign_key: 'author_id', class_name: 'Post'
7
+
8
+ # Include default devise modules. Others available are:
9
+ # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
10
+ devise :database_authenticatable, :token_authenticatable, :trackable, :omniauthable
11
+
12
+ # Setup accessible (or protected) attributes for your model
13
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :name, :is_publisher
14
+
15
+ gravtastic :gravatar_email
16
+
17
+ validate :email, uniqueness: true
18
+
19
+ def publisher!
20
+ update_attribute(:is_publisher, true)
21
+ end
22
+
23
+ def gravatar_email
24
+ (gravatar_alias || email)
25
+ end
26
+
27
+ def last_post_at
28
+ authored_posts.published_and_ordered.first.try(:published_at)
29
+ end
30
+ end
31
+ end
32
+
@@ -0,0 +1,5 @@
1
+ class PostSweeper < ActionController::Caching::Sweeper
2
+ observe Crowdblog::Post
3
+
4
+ # Implement it in your base app!
5
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: utf-8
2
+
3
+ class AttachmentUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ # storage :file
11
+ #storage :fog
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "#{model.class.to_s.underscore}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ # end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ # Create different versions of your uploaded files:
32
+ # version :thumb do
33
+ # process :scale => [50, 50]
34
+ # end
35
+
36
+ # Add a white list of extensions which are allowed to be uploaded.
37
+ # For images you might use something like this:
38
+ # def extension_white_list
39
+ # %w(jpg jpeg gif png)
40
+ # end
41
+
42
+ # Override the filename of the uploaded files:
43
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
44
+ # def filename
45
+ # "something.jpg" if original_filename
46
+ # end
47
+
48
+ end
@@ -0,0 +1,18 @@
1
+ h1 Authors
2
+
3
+ table.table.table-striped
4
+ thead
5
+ tr
6
+ th
7
+ th Name
8
+ th Email
9
+ th Posts
10
+ th Last Post
11
+ tbody
12
+ - @authors.each do |author|
13
+ tr
14
+ th= image_tag author.gravatar_url
15
+ td= author.name
16
+ td= author.email
17
+ td= author.authored_posts.count
18
+ td= author.last_post_at
@@ -0,0 +1,13 @@
1
+ h1 Posts
2
+
3
+ #posts.container
4
+
5
+ - content_for :scripts do
6
+ coffee:
7
+ $ ->
8
+ new PostsApp.PostsView
9
+ PostsApp.router = new PostsApp.Router
10
+ Backbone.history.start()
11
+
12
+ javascript:
13
+ PostsApp.publisher = #{current_user.is_publisher?}
@@ -0,0 +1,25 @@
1
+ doctype html
2
+ html
3
+ head
4
+ title Crowd Blog
5
+
6
+ = stylesheet_link_tag :crowdblog, media: 'all'
7
+ = javascript_include_tag :crowdblog
8
+ = csrf_meta_tags
9
+
10
+ = yield :scripts
11
+
12
+ body
13
+ .navbar
14
+ .navbar-inner
15
+ .container
16
+ .row
17
+ .span9
18
+ = image_tag 'crowdblog/logo.png'
19
+ .span3
20
+ ul.nav
21
+ li= link_to 'Posts', posts_path
22
+ li= link_to 'Authors', authors_path
23
+ li= link_to 'Sign out', destroy_user_session_path
24
+
25
+ .container= yield
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --color --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --color --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --color --format rerun --out rerun.txt --strict --tags ~@wip
data/config/routes.rb ADDED
@@ -0,0 +1,14 @@
1
+ Crowdblog::Engine.routes.draw do
2
+
3
+ devise_for :users, class_name: 'Crowdblog::User',
4
+ controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
5
+
6
+ resources :authors, only: :index
7
+
8
+ resources :posts do
9
+ resources :assets
10
+ end
11
+
12
+ root to: 'posts#index'
13
+
14
+ end
data/crowdblog.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require 'crowdblog/version'
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |s|
8
+ s.name = 'crowdblog'
9
+ s.version = Crowdblog::VERSION
10
+ s.authors = ['Crowd Interactive', 'David Padilla','Chalo Fernandez']
11
+ s.email = %w(opensource@crowdint.com david@crowdint.com chalofa@crowdint.com)
12
+ s.homepage = 'http://github.com/crowdint/crowdblog'
13
+ s.summary = 'CrowdBlog base functionality and backend'
14
+ s.description = 'This mountable engine has the basic functionality to manage Posts'
15
+
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.require_paths = %w(lib app)
20
+
21
+ s.add_dependency 'rails', '~> 3.2'
22
+
23
+ # Added in the Gemfile, so they can be accessed in the dummy app
24
+ # leave the dependencies here so our engine require those gems when added on base apps
25
+ s.add_dependency 'jquery-rails'
26
+ s.add_dependency 'backbone-rails'
27
+ s.add_dependency 'carrierwave'
28
+ s.add_dependency 'devise'
29
+ s.add_dependency 'eco'
30
+ s.add_dependency 'gravtastic'
31
+ s.add_dependency 'less-rails-bootstrap'
32
+ s.add_dependency 'omniauth-google-apps'
33
+ s.add_dependency 'omniauth-google-oauth2'
34
+ s.add_dependency 'slim_assets'
35
+ s.add_dependency 'slim-rails'
36
+ s.add_dependency 'state_machine'
37
+
38
+ s.add_development_dependency 'cucumber-rails'
39
+ s.add_development_dependency 'database_cleaner'
40
+ s.add_development_dependency 'fuubar'
41
+ s.add_development_dependency 'rspec-rails'
42
+ s.add_development_dependency 'simplecov'
43
+ s.add_development_dependency 'simplecov-rcov-text'
44
+ s.add_development_dependency 'sqlite3'
45
+ #s.add_development_dependency 'vestal_versions' # using git version in Gemfile
46
+ end
@@ -0,0 +1,10 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :name
5
+ t.boolean :is_publisher
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,56 @@
1
+ class AddDeviseToUsers < ActiveRecord::Migration
2
+ def self.up
3
+ change_table(:users) do |t|
4
+ ## Database authenticatable
5
+ t.string :email, :null => false, :default => ""
6
+ t.string :encrypted_password, :null => false, :default => ""
7
+
8
+ ## Recoverable
9
+ #t.string :reset_password_token
10
+ #t.datetime :reset_password_sent_at
11
+
12
+ ## Rememberable
13
+ t.datetime :remember_created_at
14
+
15
+ ## Trackable
16
+ t.integer :sign_in_count, :default => 0
17
+ t.datetime :current_sign_in_at
18
+ t.datetime :last_sign_in_at
19
+ t.string :current_sign_in_ip
20
+ t.string :last_sign_in_ip
21
+
22
+ ## Encryptable
23
+ # t.string :password_salt
24
+
25
+ ## Confirmable
26
+ # t.string :confirmation_token
27
+ # t.datetime :confirmed_at
28
+ # t.datetime :confirmation_sent_at
29
+ # t.string :unconfirmed_email # Only if using reconfirmable
30
+
31
+ ## Lockable
32
+ # t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33
+ # t.string :unlock_token # Only if unlock strategy is :email or :both
34
+ # t.datetime :locked_at
35
+
36
+ ## Token authenticatable
37
+ t.string :authentication_token
38
+
39
+
40
+ # Uncomment below if timestamps were not included in your original model.
41
+ # t.timestamps
42
+ end
43
+
44
+ add_index :users, :email, :unique => true
45
+ #add_index :users, :reset_password_token, :unique => true
46
+ # add_index :users, :confirmation_token, :unique => true
47
+ # add_index :users, :unlock_token, :unique => true
48
+ add_index :users, :authentication_token, :unique => true
49
+ end
50
+
51
+ def self.down
52
+ # By default, we don't want to make any assumption about how to roll back a migration when your
53
+ # model already existed. Please edit below which fields you would like to remove in this migration.
54
+ raise ActiveRecord::IrreversibleMigration
55
+ end
56
+ end
@@ -0,0 +1,13 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+ t.string :title
5
+ t.text :body
6
+ t.boolean :published
7
+ t.string :permalink
8
+ t.date :published_at
9
+
10
+ t.timestamps
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,6 @@
1
+ class AddAuthorToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :author_id, :integer
4
+
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class AddStateToPost < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :state, :string
4
+ add_column :posts, :publisher_id, :integer
5
+ remove_column :posts, :published
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ class CreateAssets < ActiveRecord::Migration
2
+ def change
3
+ create_table :assets do |t|
4
+ t.integer :post_id
5
+ t.string :attachment
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class AddAliasToUsers < ActiveRecord::Migration
2
+ def change
3
+ add_column :users, :gravatar_alias, :string
4
+
5
+ end
6
+ end