From 09026a2e4bd1f62935c6dc81c70dfde460f6cdd1 Mon Sep 17 00:00:00 2001 From: Luke Barratt Date: Fri, 2 May 2014 09:27:18 +0100 Subject: [PATCH] Refactor some article views Tweak colour brightnesses --- app/assets/stylesheets/components/_tables.scss | 7 ++++++- app/assets/stylesheets/layout/_body.scss | 9 ++++++--- app/assets/stylesheets/pages/_forums.scss | 3 ++- app/assets/stylesheets/pages/_news.scss | 2 ++ app/controllers/articles_controller.rb | 1 - app/helpers/articles_helper.rb | 12 ++++++++++++ app/views/articles/_article.html.erb | 6 ------ app/views/articles/_preview.html.erb | 16 +--------------- app/views/articles/news_index.html.erb | 4 +++- app/views/layouts/application.html.erb | 2 +- 10 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 app/helpers/articles_helper.rb diff --git a/app/assets/stylesheets/components/_tables.scss b/app/assets/stylesheets/components/_tables.scss index 35eef7c..4213b22 100644 --- a/app/assets/stylesheets/components/_tables.scss +++ b/app/assets/stylesheets/components/_tables.scss @@ -25,6 +25,11 @@ tr, td, th { vertical-align: middle; } +/* + Striped Tables +*/ + + table.striped > tbody { > tr { td:first-child, @@ -39,7 +44,7 @@ table.striped > tbody { } > tr:nth-child(2n) td { - background-color: transparentize($light-blue, 0.8); + background-color: transparentize($light-blue, 0.9); } .actions { diff --git a/app/assets/stylesheets/layout/_body.scss b/app/assets/stylesheets/layout/_body.scss index e596cce..7db6d4f 100644 --- a/app/assets/stylesheets/layout/_body.scss +++ b/app/assets/stylesheets/layout/_body.scss @@ -47,10 +47,13 @@ body#tinymce { box-shadow: $content-shadow; background: white; padding: 20px; -} -#main_nobody { - @include span-columns(9 of 12); + &.no-body { + box-shadow: none; + border-radius: 0; + background: transparent; + padding: 0; + } } #sidebar { diff --git a/app/assets/stylesheets/pages/_forums.scss b/app/assets/stylesheets/pages/_forums.scss index bf59dfd..f3195bf 100644 --- a/app/assets/stylesheets/pages/_forums.scss +++ b/app/assets/stylesheets/pages/_forums.scss @@ -120,8 +120,9 @@ div#categories { @include span-columns(12); padding: 20px; margin-bottom: 20px; - background: transparentize($light-gray, 0.5); + background: transparentize($light-gray, 0.75); border-radius: 5px; + box-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.2); &:last-child { margin-bottom: 40px; diff --git a/app/assets/stylesheets/pages/_news.scss b/app/assets/stylesheets/pages/_news.scss index 31ef3a2..70d5430 100644 --- a/app/assets/stylesheets/pages/_news.scss +++ b/app/assets/stylesheets/pages/_news.scss @@ -45,11 +45,13 @@ div.article { } &.preview { + @include span-columns(12); border-radius: $base-border-radius; background: white; padding: 20px; margin-bottom: 20px; box-shadow: $light-shadow; + border: 0; .content { margin-bottom: 10px; diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb index d36f11d..d0509e3 100644 --- a/app/controllers/articles_controller.rb +++ b/app/controllers/articles_controller.rb @@ -8,7 +8,6 @@ class ArticlesController < ApplicationController def news_index @news = Article.with_comments.ordered.nodrafts.onlynews.limit(10) @categories = Category.ordered.domain(Category::DOMAIN_NEWS) - @nobody = true end def news_archive diff --git a/app/helpers/articles_helper.rb b/app/helpers/articles_helper.rb new file mode 100644 index 0000000..105f8c5 --- /dev/null +++ b/app/helpers/articles_helper.rb @@ -0,0 +1,12 @@ +module ArticlesHelper + def preview_text(article, full) + if article.text_coding == Article::CODING_HTML + content = article.text.html_safe + else + content = article.text_parsed.html_safe + end + + content = truncate(raw(strip_tags(content)), length: 200) if !full + content + end +end diff --git a/app/views/articles/_article.html.erb b/app/views/articles/_article.html.erb index 05a24f0..57df68a 100644 --- a/app/views/articles/_article.html.erb +++ b/app/views/articles/_article.html.erb @@ -13,12 +13,6 @@ <%= namelink(article.user) %> on <%= longtime article.created_at %> -
- <%= link_to article do %> - <%= icon 'comments' %> Comments (<%= article.comments.count %>) - <% end %> -
-
<% if article.can_update? cuser %> <%= link_to 'Edit', edit_article_path(article), class: 'button tiny' %> diff --git a/app/views/articles/_preview.html.erb b/app/views/articles/_preview.html.erb index ce78da5..f19b6f7 100644 --- a/app/views/articles/_preview.html.erb +++ b/app/views/articles/_preview.html.erb @@ -2,21 +2,7 @@

<%= namelink article %>

- <% if article.text_coding == Article::CODING_HTML %> - <% - content = article.text.html_safe - content = truncate(raw(strip_tags(article.text)), length: 200) if !expanded - %> - - <%= content %> - <% else %> - <% - content = article.text_parsed.html_safe - content = truncate(raw(strip_tags(article.text_parsed)), length: 200) if !expanded - %> - - <%= content %> - <% end %> + <%= preview_text(article, full) %>
diff --git a/app/views/articles/news_index.html.erb b/app/views/articles/news_index.html.erb index 4feec5c..9c5f590 100644 --- a/app/views/articles/news_index.html.erb +++ b/app/views/articles/news_index.html.erb @@ -1,6 +1,8 @@ +<% provide :main_class, 'no-body' %> +
<% @news.each_with_index do |item, i| %> - <%= render partial: 'preview', locals: { article: item, expanded: (true if i == 0) } %> + <%= render partial: 'preview', locals: { article: item, full: (true if i == 0) } %> <% end %>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 13e4593..e1b565b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,7 +16,7 @@ <%= render partial: "navigation" %>
-
+
<%= render partial: "messages" %> <%= yield %>