Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 13 files changed
  • 0 commit comments
  • 1 contributor
View
5 app/cells/article_cell.rb
@@ -17,11 +17,6 @@ def comments(args)
render
end
- def published_categories_list(args)
- @categories = Category.all_published
- render
- end
-
private
def fill_generic_variables(state, opts)
View
3  app/cells/article_cell.yml
@@ -14,6 +14,3 @@ cell:
serialized_attributes:
div_id: string
div_class: string
- - name: Categories
- method: published_categories_list
- desc: List all the categories with published articles
View
2  ...rticle/published_categories_list.html.erb → ...content/articles_categories_list.html.erb
@@ -1,5 +1,5 @@
<ul>
<% @categories.each do |category| %>
- <li><%= link_to "#{category.name} (#{category.articles_count})", show_category_path(:pretty_url => category.pretty_url) %></li>
+ <li><%= link_to "#{category.name} (#{category.articles_count})", "#{@url}?category=#{category.pretty_url}" %></li>
<% end %>
</ul>
View
2  app/cells/content/articles_list.html.erb
@@ -1,4 +1,5 @@
<div class="articles_list">
+ <h1><%= @meta_title %></h1>
<% @articles.map do |a| %>
<div id="article_<%= a.id %>">
<h2><%= a.title %></h2>
@@ -7,4 +8,5 @@
<div><%= link_to "Full article", get_article_url(a) %></div>
</div>
<% end %>
+ <%= will_paginate @articles %>
</div>
View
43 app/cells/content_cell.rb
@@ -5,43 +5,62 @@ class ContentCell < Cell::Rails
helper_method :current_user
include Cell::Filters
before_filter :fill_generic_variables
-
+
## Before filter not working as 'args' is unavailable in the filter
# before_filter {|controller| controller.fill_generic_variables(args[:page], args[:options], args[:snip_id]) }
-
+
def text_widget(args)
render
end
-
+
def rich_text_widget(args)
render
end
-
+
def articles_list(args)
- @articles = Article.published.where("lang = ?", get_lang).includes(:categorizations)
+ @articles = Article.published.where(:lang => get_lang).includes(:categorizations)
@articles = @articles.not_reserved unless (args[:current_user] && args[:current_user].is_privileged?)
- @articles = @articles.where("categorizations.category_id IN (?)", args[:options][:categories]) if (args[:options] && args[:options][:categories])
+
+ if params[:category].blank?
+ # show all configured categories
+ @meta_title = I18n.t 'public.articles.all_categories'
+ @articles = @articles.where("categorizations.category_id IN (?)", args[:options][:categories]) if args[:options][:categories]
+ else
+ # show only current category
+ @meta_title = I18n.t 'public.articles.category', :name => Category.find_by_pretty_url( params[:category] ).name
+ @articles = @articles.joins(:categories).where( "categories.pretty_url = ?", params[:category] )
+ end
+
+ per_page = ( args[:options][:per_page].blank? )? 10 : args[:options][:per_page]
+ @articles = @articles.paginate( :page => params[:page], :per_page => per_page )
+
+ render
+ end
+
+ def articles_categories_list(args)
+ @categories = Category.all_published
+ @url = args[:options][:archive_url]
render
end
-
+
def twitter_stream(args)
render
end
-
+
def downloads_widget(args)
@snippet = Snippet.find(args[:snip_id])
@downloads = @snippet.uploads
render
end
-
+
def image_gallery_widget(args)
@snippet = Snippet.find(args[:snip_id])
@images = Image.where(:attachable_type => "Snippet", :attachable_id => @snippet.id)
render
end
-
+
private
-
+
def fill_generic_variables(state, opts)
@page = opts[:page] ||= yard_home
@options = opts[:options] ||= {}
@@ -53,5 +72,5 @@ def fill_generic_variables(state, opts)
def cfg
Setting.first
end
-
+
end
View
6 app/cells/content_cell.yml
@@ -21,8 +21,14 @@ cell:
desc: A list of articles with category filter
serialized_attributes:
categories: article_categories
+ per_page: integer
div_id: string
div_class: string
+ - name: Articles Categories
+ method: articles_categories_list
+ desc: List all the categories with published articles
+ serialized_attributes:
+ archive_url: string
- name: Twitter stream
method: twitter_stream
desc: Stream of tweets from a twitter account
View
24 app/controllers/categories_controller.rb
@@ -1,24 +0,0 @@
-class CategoriesController < ApplicationController
-
- def show
- @layout = ArticleLayout.find_by_lang( params[:lang] )
- @category = Category.where( :pretty_url => params[:pretty_url] ).first
- @articles = @category.articles.select do |a|
- check_permission(a, current_user) && check_publish_status(a)
- end
- @meta_title = "#{I18n.t('admin.general.category')} #{@category.name}"
-
- render :layout => Layout.find(@cfg.theme_name, @layout.layout_name).path
- end
-
-private
-
- def check_publish_status(article)
- true if article.published && (article.publish_at < Time.zone.now)
- end
-
- def check_permission(article, user)
- true unless article.reserved && (user.nil? or (!user.nil? && !user.is_privileged?))
- end
-
-end
View
13 app/views/categories/show.html.erb
@@ -1,13 +0,0 @@
-<% # FIXME: for categories#show %>
-<% content_for :categories do %>
-<%= render_cell :article, :published_categories_list, :user => current_user %>
-<% end %>
-
-<h1><%= @meta_title %></h1>
-<% @articles.each do |article| %>
-<div>
- <h2><%= article.title %></h2>
- <div><%= article.short.html_safe %></div>
- <%= link_to t( 'public.articles.more' ), get_article_url(article) %>
-</div>
-<% end %>
View
3  config/locales/en.yml
@@ -255,7 +255,8 @@ en:
articles:
articles: Articles
article: Article
- more: "Read more..."
+ all_categories: "All categories"
+ category: "Articles in category %{name}"
pages:
pages: Pages
page: Page
View
3  config/locales/it.yml
@@ -249,7 +249,8 @@ it:
articles:
articles: Articoli
article: Articolo
- more: "Leggi tutto..."
+ all_categories: "Tutte le categorie"
+ category: "Articoli nella categoria %{name}"
pages:
pages: Pagine
page: Pagina
View
1  config/routes.rb
@@ -61,7 +61,6 @@
resources :users
resources :comments
match ':lang/article/:year/:month/:day/:pretty_url' => 'articles#show', :as => 'show_article', :constraints => {:lang => $AVAILABLE_LANGUAGES, :year => /\d+/, :month => /\d+/, :day => /\d+/}
- match ':lang/category/:pretty_url' => 'categories#show', :as => 'show_category', :constraints => {:lang => $AVAILABLE_LANGUAGES}
# Main public pages globbing route
match '/:lang' => "site#show", :constraints => {:lang => /[a-z]{2}/}
View
13 features/access_admin_panel.feature
@@ -2,7 +2,7 @@ Feature: Accessing the admin panel
In order to manage the page
As a user
I want to access the admin panel
-
+
Scenario: Sign in as a admin
Given the page is setup in basic mode
And I go to the admin page
@@ -12,13 +12,14 @@ Feature: Accessing the admin panel
And I press "Sign in"
And I should be on the admin pages page
And I should see "Pages list" within "header"
-
+
# Scenario added for bugfix in commit:5c618b6
Scenario: Create a new page without having a page before
Given the page is setup in basic mode
And I am logged in as "admin@example.com" with password "changeme"
And I go to the admin page
- When I follow "Delete" within "table.datatable"
+ When I follow "Properties" within "table.datatable"
+ And I follow "Delete"
And I go to the new admin page page
And I fill in "title" with "My new page"
And I check "page_visible_in_menu"
@@ -28,7 +29,7 @@ Feature: Accessing the admin panel
Then I should be on the admin pages page
And I should not see "Home en" within "#pages-tree"
And I should see "My new page" within "#pages-tree"
-
+
Scenario: Create a new page
Given the page is setup in basic mode
And I am logged in as "admin@example.com" with password "changeme"
@@ -41,7 +42,7 @@ Feature: Accessing the admin panel
Then I should be on the admin pages page
And I should see "Home en" within "#pages-tree"
And I should see "My new page" within "#pages-tree"
-
+
Scenario: Create a new page with double pretty url
Given the page is setup in basic mode
And I am logged in as "admin@example.com" with password "changeme"
@@ -53,7 +54,7 @@ Feature: Accessing the admin panel
And I press "Save"
Then I should be on the admin pages page
And I should see "There was a problem creating the page" within ".alert"
-
+
Scenario: Show the content area of a page
Given the page is setup in basic mode
And I am logged in as "admin@example.com" with password "changeme"
View
2  features/admin_pages.feature
@@ -70,4 +70,4 @@ Feature: Manage pages admin panel and check effects on public side
-
+

No commit comments for this range

Something went wrong with that request. Please try again.