Improve news page layout

Fix forums unread icon
Fix double linebreaks in BBcode
Increase colour darkness
This commit is contained in:
Luke Barratt 2014-04-29 21:02:20 +01:00
parent b709d11783
commit 5ed4dd1891
15 changed files with 73 additions and 26 deletions

View file

@ -59,7 +59,7 @@ $dark-gray: #21262A;
$medium-gray: #2F383D; $medium-gray: #2F383D;
$light-blue: darken(#2FB0E7, 10); $light-blue: darken(#2FB0E7, 10);
$light-gray: #ECF1F5; $light-gray: darken(#ECF1F5, 10);
$light-red: #e56c69; $light-red: #e56c69;
$light-yellow: #FFF6BF; $light-yellow: #FFF6BF;
$light-green: #1f7f5c; $light-green: #1f7f5c;
@ -106,3 +106,4 @@ $button-text: white;
*/ */
$content-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.15); $content-shadow: 0px 5px 15px 0px rgba(0, 0, 0, 0.15);
$light-shadow: 0px 2px 5px 0px rgba(0, 0, 0, 0.1);

View file

@ -8,6 +8,7 @@
a { a {
display: inline-block; display: inline-block;
font-size: $base-font-size + 2px;
} }
.fa { .fa {

View file

@ -42,7 +42,7 @@ form {
} }
.select-wrapper { .select-wrapper {
$select-padding: 7px; $select-padding: 6px;
$select-height: $input-height - 4px; $select-height: $input-height - 4px;
border-radius: $input-border-radius; border-radius: $input-border-radius;

View file

@ -103,13 +103,12 @@
#gather-area { #gather-area {
@include span-columns(12); @include span-columns(12);
$column-border-width: 15px; $column-border-width: 10px;
$column-border-radius: 5px; $column-border-radius: 5px;
.gather-columns { .gather-columns {
@include span-columns(12); @include span-columns(12);
@include row(table); @include row(table);
margin-bottom: 20px;
margin-left: - $column-border-width; margin-left: - $column-border-width;
width: $max-width - ($column-border-width*2); width: $max-width - ($column-border-width*2);
} }
@ -119,7 +118,7 @@
@include pad; @include pad;
border-radius: $column-border-width + $column-border-radius; border-radius: $column-border-width + $column-border-radius;
padding-bottom: 20px; padding-bottom: 20px;
background: $light-gray; background: lighten($light-gray, 5%);
padding: 20px; padding: 20px;
border: $column-border-width solid white; border: $column-border-width solid white;

View file

@ -39,7 +39,7 @@ table.striped > tbody {
} }
> tr:nth-child(2n) td { > tr:nth-child(2n) td {
background-color: transparentize($light-blue, 0.95); background-color: transparentize($light-blue, 0.8);
} }
.actions { .actions {

View file

@ -34,11 +34,12 @@
*/ */
.highlight { .highlight {
font-size: 14px; font-size: 12px;
line-height: 18px;
border-radius: 3px; border-radius: 3px;
background: $blue; background: $blue;
color: white; color: white;
display: inline-block; display: inline-block;
font-style: italic; font-style: italic;
padding: 0 6px; padding: 0 3px;
} }

View file

@ -34,7 +34,7 @@ div#categories {
repeat: no-repeat; repeat: no-repeat;
} }
&.highlight { &.updated {
background-image: image-url('layout/forum-category-highlight.png'); background-image: image-url('layout/forum-category-highlight.png');
} }
} }

View file

@ -15,6 +15,10 @@ div.article {
@include span-columns(12); @include span-columns(12);
margin-bottom: 40px; margin-bottom: 40px;
* {
font-family: $open-sans !important;
}
ul { ul {
@extend ul.disc; @extend ul.disc;
} }
@ -44,11 +48,20 @@ div.article {
margin-top: 10px; margin-top: 10px;
} }
&:first-child { &.preview {
border-radius: $base-border-radius;
background: lighten($light-gray, 5%);
padding: 20px;
margin-bottom: 20px;
box-shadow: $light-shadow;
.content {
margin-bottom: 10px;
}
h1 { h1 {
margin-top: 0; margin: 0 0 .5em 0;
} }
} }
} }

View file

@ -6,7 +6,7 @@ class ArticlesController < ApplicationController
end end
def news_index def news_index
@news = Article.with_comments.ordered.limited.nodrafts.onlynews @news = Article.with_comments.ordered.nodrafts.onlynews.limit(10)
@categories = Category.ordered.domain(Category::DOMAIN_NEWS) @categories = Category.ordered.domain(Category::DOMAIN_NEWS)
@nobody = true @nobody = true
end end

View file

@ -40,6 +40,10 @@ module ApplicationHelper
printtime time, "%d %B %y %H:%M" printtime time, "%d %B %y %H:%M"
end end
def longertime time
printtime time, "%e %B %Y - %H:%M %Z"
end
def shorttime time def shorttime time
printtime time, "%d/%b/%y %H:%M" printtime time, "%d/%b/%y %H:%M"
end end
@ -55,12 +59,9 @@ module ApplicationHelper
def printtime time, format def printtime time, format
return unless time return unless time
out = "" content_tag(:span, style: 'font-style: italic') do
out << '<span style="font-style: italic; ">' Time.use_zone(timezone_offset) { time.strftime(format) }
out << time.strftime(format) end
out << '</span>'
out.html_safe
end end
def cascade model, list def cascade model, list

View file

@ -26,7 +26,7 @@ module Extra
end end
def bbcode_to_html(text) def bbcode_to_html(text)
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br>").html_safe Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\r/, "<br>").html_safe
end end
def move_up(scope, column = "position") def move_up(scope, column = "position")

View file

@ -0,0 +1,31 @@
<div class="article preview">
<h1><%= namelink article %></h1>
<div class="content">
<% 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 %>
</div>
<div class="author">
<%= namelink(article.user) %> on <%= longertime article.created_at %>
</div>
<div class="comments">
<%= link_to article do %>
<%= icon 'comments' %> Comments (<%= article.comments.count %>)
<% end %>
</div>
</div>

View file

@ -1,11 +1,11 @@
<div id="news"> <div id="news">
<% @news.each do |item| %> <% @news.each_with_index do |item, i| %>
<%= render partial: "article", locals: { article: item } %> <%= render partial: 'preview', locals: { article: item, expanded: (true if i == 0) } %>
<% end %> <% end %>
</div> </div>
<div class="actions-bottom"> <div class="actions-bottom">
<%= link_to t('news.archive'), '/news/archive', class: "button" %> <%= link_to t('news.archive'), '/news/archive', class: 'button' %>
<% if cuser and cuser.admin? %> <% if cuser and cuser.admin? %>
<%= link_to t('helpers.submit.post.new'), new_article_path, class: "button" %> <%= link_to t('helpers.submit.post.new'), new_article_path, class: "button" %>

View file

@ -16,7 +16,7 @@
<% forums.each do |forum| %> <% forums.each do |forum| %>
<tr> <tr>
<td class="bullet <%= "highlight" if cuser and !forum.read_by?(cuser) %>"></td> <td class="bullet <%= "updated" if cuser and !forum.read_by?(cuser) %>"></td>
<td class="forum"> <td class="forum">
<h5><%= namelink(forum) %></h5> <h5><%= namelink(forum) %></h5>
<%= forum.description %> <%= forum.description %>

View file

@ -26,7 +26,7 @@
<div class="header"> <div class="header">
<div class="time"> <div class="time">
<span id="post_<%= post.id %>"> <span id="post_<%= post.id %>">
<%= longtime(post.created_at) %> <%= longertime post.created_at %>
</span> </span>
</div> </div>
<div class="posts"> <div class="posts">