Skip to content

Commit

Permalink
implement basic entries list
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Schubert committed Dec 11, 2014
1 parent 54c3b9d commit c2c6e1c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 22 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@ gem 'rails_admin'
gem 'rails_locale_detection', '~> 2.0.0.pre'

gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass', '~> 3.2.0'
gem 'bootstrap-sass', '~> 3.3.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'will_paginate-bootstrap'

gem 'redcarpet', '~> 3.2'
gem 'paperclip', '~> 4.1'

gem 'feedjira', github: 'feedjira/feedjira'
gem 'trollop', '~> 2.0'
gem 'sanitize', '~> 3.0.0'

group :development, :test do
gem 'pry'
Expand Down
16 changes: 14 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ GEM
arel (5.0.1.20140414130214)
awesome_print (1.2.0)
bcrypt (3.1.9)
bootstrap-sass (3.2.0.2)
bootstrap-sass (3.3.1.0)
sass (~> 3.2)
builder (3.2.2)
capybara (2.4.4)
Expand All @@ -60,6 +60,7 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.8.0)
crass (0.2.1)
curb (0.8.6)
devise (3.4.1)
bcrypt (~> 3.0)
Expand Down Expand Up @@ -104,6 +105,8 @@ GEM
nested_form (0.3.2)
nokogiri (1.6.5)
mini_portile (~> 0.6.0)
nokogumbo (1.1.12)
nokogiri
orm_adapter (0.5.0)
paperclip (4.2.1)
activemodel (>= 3.0.0)
Expand Down Expand Up @@ -182,6 +185,10 @@ GEM
rspec-support (3.1.2)
ruby-progressbar (1.7.0)
safe_yaml (1.0.4)
sanitize (3.0.3)
crass (~> 0.2.0)
nokogiri (>= 1.4.4)
nokogumbo (= 1.1.12)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
Expand Down Expand Up @@ -216,6 +223,9 @@ GEM
raindrops (~> 0.7)
warden (1.2.3)
rack (>= 1.0)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)
xpath (2.0.0)
nokogiri (~> 1.3)

Expand All @@ -224,7 +234,7 @@ PLATFORMS

DEPENDENCIES
awesome_print
bootstrap-sass (~> 3.2.0)
bootstrap-sass (~> 3.3.0)
capybara (~> 2.4.1)
coffee-rails (~> 4.0)
devise (~> 3.4.0)
Expand All @@ -240,8 +250,10 @@ DEPENDENCIES
redcarpet (~> 3.2)
rspec-instafail (~> 0.2.4)
rspec-rails (~> 3.0)
sanitize (~> 3.0.0)
sass-rails (~> 4.0.0)
trollop (~> 2.0)
turbolinks
uglifier (>= 1.3.0)
unicorn
will_paginate-bootstrap
13 changes: 13 additions & 0 deletions app/controllers/planet_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class PlanetController < ApplicationController
respond_to :html, :except => [:feed]
respond_to :atom, :only => [:feed]

def index
@entries = Planet::Models::Entry.order(:published_at => :desc)
.paginate(:page => params[:page], :per_page => 10)
end

def feed
# TODO implement me
end
end
22 changes: 22 additions & 0 deletions app/views/planet/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<%- content_for :page_title do %>
<%= t 'pages.planet.menu_title' %>
<% end %>

<div class="page-header">
<h1><%= t 'pages.planet.headline' %> <small><%= t 'pages.planet.subline' %></small></h1>
</div>

<%- @entries.each do |entry| %>
<div class="blogcontent bloglist-item">
<div class="page-header clearfix">
<h1>
<%= entry.feed.title %> - <%= link_to entry.title, entry.url %>
<small><%= l entry.published_at, format: :blog_headline %></small>
</h1>
</div>

<%= entry.sanitized_body.html_safe %>
</div>
<% end %>
<%= will_paginate @entries, renderer: BootstrapPagination::Rails %>
3 changes: 2 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ en:
subline: "official announcements"
menu_title: Blog
planet:
headline: Planet
headline: "The diaspora* planet"
subline: "blog posts by our community"
menu_title: Planet
tutorials:
headline: "diaspora* tutorials"
Expand Down
41 changes: 23 additions & 18 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@
get 'switch_locale/:locale' => 'i18n#switch_locale', as: :switch_locale

constraints subdomain: /^(|www)$/i do
controller :pages do
get :about
get :get_involved
get :tutorials
scope 'getting_started' do
get :sign_up, action: 'getting_started1'
get :interface, action: 'getting_started2'
get :aspects, action: 'getting_started3'
get :connecting, action: 'getting_started4'
get :sharing, action: 'getting_started5'
get :conversations, action: 'getting_started6'
get :finishing, action: 'getting_started7'
end
get :formatting
get :tips
get :other_docs
end
controller :pages do
get :about
get :formatting
get :get_involved
get :other_docs
get :tips
get :tutorials
scope 'getting_started' do
get :aspects, action: 'getting_started3'
get :connecting, action: 'getting_started4'
get :conversations, action: 'getting_started6'
get :finishing, action: 'getting_started7'
get :interface, action: 'getting_started2'
get :sharing, action: 'getting_started5'
get :sign_up, action: 'getting_started1'
end
end

root to: 'pages#index'
end
Expand All @@ -29,8 +29,13 @@
mount RailsAdmin::Engine => '/', as: 'rails_admin'
end

constraints subomdain: /^blog$/i do
constraints subdomain: /^blog$/i do
get 'feed' => 'blog#feed', :as => :news_feed, :defaults => {:format => :atom}
resources :blog, path: '/', only: [:index, :show]
end

constraints subdomain: /^planet$/i do
get 'feed' => 'planet#feed', :as => :planet_feed, :defaults => {:format => :atom}
get '/' => 'planet#index'
end
end
9 changes: 9 additions & 0 deletions lib/planet/models/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ class Entry < ActiveRecord::Base
belongs_to :feed
validates_presence_of :entry_id, :feed, :title, :body, :url
validates_uniqueness_of :entry_id

def sanitized_body
Sanitize.fragment(self.body, Sanitize::Config.merge(
Sanitize::Config::RELAXED,
:add_attributes => {
'a' => {'rel' => 'nofollow'}
}
))
end
end
end
end

0 comments on commit c2c6e1c

Please sign in to comment.