diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..dfe07704 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/.gitignore b/.gitignore index f80f8803..a373c1e4 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,10 @@ coverage/ .idea/ .idea/**/* -Gemfile.lock \ No newline at end of file +Gemfile.lock +*.lock + +.ruby-version +.rbenv-version +.rvmrc + diff --git a/.rbenv-version b/.rbenv-version deleted file mode 100644 index 0ca8caf7..00000000 --- a/.rbenv-version +++ /dev/null @@ -1 +0,0 @@ -1.9.3-p327 diff --git a/.rvmrc b/.rvmrc deleted file mode 100644 index 90364e8e..00000000 --- a/.rvmrc +++ /dev/null @@ -1 +0,0 @@ -rvm use 1.9.3@monologue --create diff --git a/.travis.yml b/.travis.yml index 24ca7ee6..f8244a11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,21 @@ language: ruby + before_script: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - mv spec/dummy/config/database-travis.yml spec/dummy/config/database.yml - bundle exec rake db:create db:migrate + rvm: - - 1.9.3 - 2.0.0 + - 2.1.0 + +gemfile: + - spec/support/gemfiles/rails4_0.gemfile + - spec/support/gemfiles/rails4_1.gemfile + +sudo: false + env: - DB=mysql DB_USERNAME=root - - DB=postgresql DB_USERNAME=postgres \ No newline at end of file + - DB=postgresql DB_USERNAME=postgres diff --git a/Gemfile b/Gemfile index 29865c5a..98f4b88e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,4 @@ -source "http://rubygems.org" +source "https://rubygems.org" # Declare your gem's dependencies in monologue.gemspec. # Bundler will treat runtime dependencies like base dependencies, and @@ -16,7 +16,8 @@ gemspec group :development, :test do gem "thin" - gem 'rails', '>= 4.0.4' + gem 'rails', '= 4.2.7' + gem 'responders', '~> 2.0' gem 'pry' if RUBY_PLATFORM.downcase.include?("darwin") @@ -26,5 +27,5 @@ group :development, :test do end gem 'coveralls', require: false - gem 'pg' +gem 'turbolinks' diff --git a/README.md b/README.md index 6952b0f0..44642eba 100644 --- a/README.md +++ b/README.md @@ -6,27 +6,26 @@ **THIS README IS FOR THE MASTER BRANCH AND REFLECTS THE WORK CURRENTLY EXISTING ON THE MASTER BRANCH. IF YOU ARE WISHING TO USE A NON-MASTER BRANCH OF MONOLOGUE, PLEASE CONSULT THAT BRANCH'S README AND NOT THIS ONE.** -- +**NOT MAINTAINED ANYMORE**: This project hasn't been maintained for a while. It's pretty basic and should still work. Chances are issues and PRs might not receive the attention they deserve, at least, not quickly, if at all. -Monologue is a basic mountable blogging engine in Rails built to be easily mounted in an already existing Rails app, but it can also be used alone. +Monologue is a basic, mountable blogging engine in Rails built to be easily mounted in an already existing Rails app, but it can also be used alone. ## Version -This README is for a future Monologue version, that will be 0.4.X and be Rails 4 specific. See other branches for other versions (0-3-stable being the latest stable version). +This README is for the latest version of Monologue (0-5-stable being the latest stable version). ## Upgrade and changes -To know how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/blob/master/UPGRADE.md) file. If you want to know what changed since the last versions, see [CHANGELOG.md](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md). +To learn how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/blob/master/UPGRADE.md) file. If you want to learn what changed since the last versions, see [CHANGELOG.md](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md). ## Questions? Problems? Documentation? - [Mailing list for questions](http://groups.google.com/forum/#!forum/monologue-rb) - [Issues and bugs](http://github.com/jipiboily/monologue/issues) - [Wiki](https://github.com/jipiboily/monologue/wiki/_pages) -- IRC channel (on Freenode): #monologue. ## Some features -- Rails mountable engine (fully named spaced and mountable in an already existing app) +- Rails mountable engine (fully namespaced and mountable in an already existing app) - tested - back to basics: few features - tags (or categories) @@ -46,15 +45,15 @@ To know how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/ ## Installation -### 1. Add the gem to your `Gemfile`. This will get the latest version compatible with Rails 4 until we release a gem +### 1. Add the gem to your `Gemfile`. ```ruby -gem 'monologue', github: 'jipiboily/monologue' +gem 'monologue' ``` And run `bundle install` to fetch the gem and update your 'Gemfile.lock'. ### 2. Route to Monologue -Add this to your route file (`config/route.rb`) +Add this to your route file (`config/routes.rb`) ```ruby # This line mounts Monologue's routes at the root of your application. # This means, any requests to URLs such as /my-post, will go to Monologue::PostsController. @@ -70,33 +69,37 @@ be available at `/monologue`. ### 3. Migrate Monologue's database tables Run these commands: -1. $`bundle exec rake monologue:install:migrations` -2. $`bundle exec rake db:create` (only if this is a new project) -3. $`bundle exec rake db:migrate` +1. $`bin/rake monologue:install:migrations` +2. $`bin/rake db:create` (only if this is a new project) +3. $`bin/rake db:migrate` ### 4. Create a user -Open your development console with `rails c`, then: +Open your development console with `bin/rails c`, then: ```ruby Monologue::User.create(name: "monologue", email:"monologue@example.com", password:"my-password", password_confirmation: "my-password") ``` ### 5. Configure Monologue. -This is all done in an initializer file, say `config/initializers/monologue.rb`. More on this in the [Wiki - Configuration](https://github.com/jipiboily/monologue/wiki/Configuration). +This is all done in an initializer file, typically `config/initializers/monologue.rb`. More on this in the [Wiki - Configuration](https://github.com/jipiboily/monologue/wiki/Configuration). ### 6. Ready -Start your server and head on [http://localhost:3000/monologue](http://localhost:3000/monologue) to log in the admin section. +Start your server and go to [http://localhost:3000/monologue](http://localhost:3000/monologue) to log in the admin section. ### Note to users -Monologue is using his own tables. If you want to use your own tables with monologue (for example the User table) -this might help you to monkey patch [Monkey Patch](https://gist.github.com/jipiboily/776d907fc932640ac59a) +Monologue is using its own tables. If you want to use your own tables with monologue (for example the User table) +this might help you to [monkey patch](https://gist.github.com/jipiboily/776d907fc932640ac59a). ## Customization See the [Wiki - Customizations](https://github.com/jipiboily/monologue/wiki/Customizations). +## Copy views +copy views like devise `rails g monologue:views` +or use scope: `rails g monologue:views blog` + ## Requirements -- Rails 4.0.4 + +- Rails 4.2.1 + - Database: MySQL & Postgres are supported but other databases might work too. ## Authors @@ -124,7 +127,8 @@ Starting point: * Fork the repo * Clone your repo * Run `bundle install` -* Run `bundle exec rake test_app` to create the test application in `spec/dummy` +* Run `bundle exec rake db:migrate` +* Run `bundle exec rake db:setup` * Make your changes * Ensure specs pass by running `bundle exec rspec spec` * Submit your pull request diff --git a/UPGRADE.md b/UPGRADE.md index 3c1f6027..d425b093 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,4 +1,7 @@ # Upgrade Monologue +## 0.4.0 to 0.5.0 + - No update required + ## 0.3.0 to 0.4.0 - Change of syntax for configuration. Please use Monologue::Config instead of the old Monologue module diff --git a/app/assets/javascripts/monologue/admin/application.js b/app/assets/javascripts/monologue/admin/application.js index 9fff8a52..fa7d9a21 100644 --- a/app/assets/javascripts/monologue/admin/application.js +++ b/app/assets/javascripts/monologue/admin/application.js @@ -11,7 +11,6 @@ //= require monologue/bootstrap/bootstrap-datepicker-fr //= require monologue/bootstrap/bootstrap-datepicker-pt //= require monologue/bootstrap/bootstrap-datepicker-es -//= require ckeditor/override //= require ckeditor/init //= require monologue/admin/ckeditor-config //= require monologue/admin/posts diff --git a/app/assets/javascripts/monologue/admin/ckeditor-config.js b/app/assets/javascripts/monologue/admin/ckeditor-config.js index d5918dc0..74d7c3ec 100644 --- a/app/assets/javascripts/monologue/admin/ckeditor-config.js +++ b/app/assets/javascripts/monologue/admin/ckeditor-config.js @@ -18,4 +18,5 @@ $(function() { { name: 'colors', items : [ 'TextColor','BGColor' ] }, { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] } ]; -}); \ No newline at end of file + CKEDITOR.config.disableNativeSpellChecker = false; +}()); \ No newline at end of file diff --git a/app/controllers/monologue/admin/posts_controller.rb b/app/controllers/monologue/admin/posts_controller.rb index 3f842deb..65786267 100644 --- a/app/controllers/monologue/admin/posts_controller.rb +++ b/app/controllers/monologue/admin/posts_controller.rb @@ -3,7 +3,8 @@ class Monologue::Admin::PostsController < Monologue::Admin::BaseController before_filter :load_post, only: [:edit, :update] def index - @posts = Monologue::Post.default + @page = params[:page].nil? ? 1 : params[:page] + @posts = Monologue::Post.listing_page(@page).includes(:user) end def new diff --git a/app/controllers/monologue/posts_controller.rb b/app/controllers/monologue/posts_controller.rb index f1d3c0b0..e4263514 100644 --- a/app/controllers/monologue/posts_controller.rb +++ b/app/controllers/monologue/posts_controller.rb @@ -1,7 +1,7 @@ class Monologue::PostsController < Monologue::ApplicationController def index @page = params[:page].nil? ? 1 : params[:page] - @posts = Monologue::Post.page(@page).published + @posts = Monologue::Post.page(@page).includes(:user).published end def show @@ -17,5 +17,10 @@ def show def feed @posts = Monologue::Post.published.limit(25) + if params[:tags].present? + tags = Monologue::Tag.where(name: params[:tags].split(",")).pluck(:id) + @posts = @posts.joins(:taggings).where("monologue_taggings.tag_id in (?)", tags) + end + render 'feed', layout: false end end diff --git a/app/models/monologue/post.rb b/app/models/monologue/post.rb index b9afb56e..8f11e69a 100644 --- a/app/models/monologue/post.rb +++ b/app/models/monologue/post.rb @@ -37,11 +37,11 @@ def published_in_future? end def self.page p - per_page = Monologue::Config.posts_per_page || 10 - set_total_pages(per_page) - p = (p.nil? ? 0 : p.to_i - 1) - offset = p * per_page - self.limit(per_page).offset(offset) + paged_results(p, Monologue::Config.posts_per_page || 10, false) + end + + def self.listing_page(p) + paged_results(p, Monologue::Config.admin_posts_per_page || 50, true) end def self.total_pages @@ -54,6 +54,17 @@ def self.set_total_pages per_page private + def self.paged_results(p, per_page, admin) + set_total_pages(per_page) + p = (p.nil? ? 0 : p.to_i - 1) + offset = p * per_page + if admin + default.limit(per_page).offset(offset) + else + limit(per_page).offset(offset) + end + end + def generate_url return unless self.url.blank? year = self.published_at.class == ActiveSupport::TimeWithZone ? self.published_at.year : DateTime.now.year @@ -63,5 +74,4 @@ def generate_url def url_do_not_start_with_slash errors.add(:url, I18n.t("activerecord.errors.models.monologue/post.attributes.url.start_with_slash")) if self.url.start_with?("/") end - end diff --git a/app/views/layouts/monologue/admin.html.erb b/app/views/layouts/monologue/admin.html.erb index e05d28af..8c691ac6 100644 --- a/app/views/layouts/monologue/admin.html.erb +++ b/app/views/layouts/monologue/admin.html.erb @@ -12,7 +12,7 @@ <% end %>