Added form view styling

Improved articles styling
Improved bbcode to html formatting
HTML and CSS refactorings
Moved Extra into concerns
Changed repo URL to read-only for deploys
Fixes quotes in comments
This commit is contained in:
Luke Barratt 2014-04-12 02:35:42 +01:00
parent cf8a92f628
commit 775f5682a4
42 changed files with 658 additions and 386 deletions

View file

@ -21,6 +21,7 @@ gem 'newrelic_rpm', '~> 3.7.2.195'
gem 'will_paginate', '~> 3.0.5' gem 'will_paginate', '~> 3.0.5'
gem 'dynamic_form', '~> 1.1.4' gem 'dynamic_form', '~> 1.1.4'
gem 'country_code_select', '~> 1.0.1' gem 'country_code_select', '~> 1.0.1'
gem 'active_link_to', '~> 1.0.2'
gem 'rmagick', '~> 2.13.2', require: false gem 'rmagick', '~> 2.13.2', require: false
gem 'sprockets', '~> 2.2.1' gem 'sprockets', '~> 2.2.1'
@ -45,8 +46,10 @@ group :development do
gem 'capistrano-bundler', '~> 1.1.2' gem 'capistrano-bundler', '~> 1.1.2'
gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rails', '~> 1.1'
gem 'capistrano3-unicorn', '~> 0.1.1' gem 'capistrano3-unicorn', '~> 0.1.1'
gem 'better_errors', '~> 1.1.0'
gem 'binding_of_caller', '~> 0.7.2'
gem 'annotate', '~> 2.6.2' gem 'annotate', '~> 2.6.2'
gem 'quiet_assets' gem 'quiet_assets', '~> 1.0.2'
end end
group :test do group :test do

View file

@ -14,6 +14,8 @@ GEM
rack-cache (~> 1.2) rack-cache (~> 1.2)
rack-test (~> 0.6.1) rack-test (~> 0.6.1)
sprockets (~> 2.2.1) sprockets (~> 2.2.1)
active_link_to (1.0.2)
actionpack
activemodel (3.2.17) activemodel (3.2.17)
activesupport (= 3.2.17) activesupport (= 3.2.17)
builder (~> 3.0.0) builder (~> 3.0.0)
@ -33,6 +35,11 @@ GEM
rake (>= 0.8.7) rake (>= 0.8.7)
arel (3.0.3) arel (3.0.3)
bbcoder (1.0.1) bbcoder (1.0.1)
better_errors (1.1.0)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bitters (0.9.3) bitters (0.9.3)
bourbon (>= 3.1) bourbon (>= 3.1)
sass (>= 3.2) sass (>= 3.2)
@ -86,6 +93,7 @@ GEM
activesupport (>= 3.0) activesupport (>= 3.0)
dalli (2.7.0) dalli (2.7.0)
database_cleaner (1.2.0) database_cleaner (1.2.0)
debug_inspector (0.0.2)
debugger (1.6.6) debugger (1.6.6)
columnize (>= 0.3.1) columnize (>= 0.3.1)
debugger-linecache (~> 1.2.0) debugger-linecache (~> 1.2.0)
@ -265,8 +273,11 @@ PLATFORMS
x86-mingw32 x86-mingw32
DEPENDENCIES DEPENDENCIES
active_link_to (~> 1.0.2)
annotate (~> 2.6.2) annotate (~> 2.6.2)
bbcoder (~> 1.0.1) bbcoder (~> 1.0.1)
better_errors (~> 1.1.0)
binding_of_caller (~> 0.7.2)
bitters (~> 0.9.3) bitters (~> 0.9.3)
bluecloth (~> 2.2.0) bluecloth (~> 2.2.0)
bourbon (~> 3.1.8) bourbon (~> 3.1.8)
@ -298,7 +309,7 @@ DEPENDENCIES
oj (~> 2.5.5) oj (~> 2.5.5)
poltergeist (~> 1.5.0) poltergeist (~> 1.5.0)
pry-debugger (~> 0.2.2) pry-debugger (~> 0.2.2)
quiet_assets quiet_assets (~> 1.0.2)
rails (~> 3.2.17) rails (~> 3.2.17)
rmagick (~> 2.13.2) rmagick (~> 2.13.2)
rspec-rails (~> 2.14.1) rspec-rails (~> 2.14.1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 KiB

View file

@ -191,10 +191,12 @@ function findUser(source) {
return false; return false;
} }
function QuoteText(id) { function QuoteText(id, type) {
type = type || 'posts';
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "/posts/quote/" + id + ".js", url: "/" + type + "/quote/" + id + ".js",
dataType: "script" dataType: "script"
}); });
} }

View file

@ -42,6 +42,7 @@ $base-border-radius: em(3);
Colours Colours
*/ */
$red: #de8650;
$green: #1f7f5c; $green: #1f7f5c;
$blue: #5a9aa8; $blue: #5a9aa8;
$purple: #6a5a8c; $purple: #6a5a8c;
@ -87,7 +88,7 @@ $navbar-text: white;
$flash-text: white; $flash-text: white;
$flash-notice: #5a9aa8; $flash-notice: #5a9aa8;
$flash-success: #1f7f5c; $flash-success: #1f7f5c;
$flash-warning: #de8650; $flash-warning: $red;
$flash-error: #e56c69; $flash-error: #e56c69;
$input-primary: white; $input-primary: white;

View file

@ -24,6 +24,8 @@
@import "components/flashes"; @import "components/flashes";
@import "components/comments"; @import "components/comments";
@import "components/gather"; @import "components/gather";
@import "components/breadcrumbs";
@import "components/pagination";
/* /*
Layout Layout
@ -35,6 +37,7 @@
@import "layout/body"; @import "layout/body";
@import "layout/sidebar"; @import "layout/sidebar";
@import "layout/footer"; @import "layout/footer";
@import "layout/helpers";
/* /*
Pages Pages
@ -42,3 +45,4 @@
@import "pages/news"; @import "pages/news";
@import "pages/contests"; @import "pages/contests";
@import "pages/forums";

View file

@ -0,0 +1,16 @@
/*
Breadcrumbs
*/
.breadcrumbs {
@include span-columns(12);
margin-bottom: em(20);
a {
display: inline-block;
}
.fa {
margin: 0 em(10);
}
}

View file

@ -127,7 +127,8 @@ form.square {
line-height: em(16); line-height: em(16);
} }
input { input,
textarea {
@include span-columns(9); @include span-columns(9);
} }
} }

View file

@ -0,0 +1,8 @@
/*
Pagination
*/
.pagination {
@include span-columns(12);
margin: em(20) 0;
}

View file

@ -1,10 +1,24 @@
/*
Main Containers
*/
html,
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
width: 100%;
min-height: 100%;
}
body {
background: $dark-blue; background: $dark-blue;
@include background-image(linear-gradient($dark-blue, $medium-gray)); @include background-image(linear-gradient($dark-blue, $medium-gray));
} }
#container {
min-height: 100%;
}
%container-padded { %container-padded {
padding: 0 em(20); padding: 0 em(20);
} }
@ -17,13 +31,16 @@ body {
@extend %container-padded; @extend %container-padded;
} }
#content, #content {
#forums {
@include span-columns(12); @include span-columns(12);
background: $light-blue; background: $light-blue;
padding-top: em(20); padding-top: em(20);
} }
#forums {
@include span-columns(12);
}
#main { #main {
@include span-columns(9); @include span-columns(9);
} }
@ -32,14 +49,3 @@ body {
@include span-columns(3); @include span-columns(3);
@include omega(); @include omega();
} }
img.flag {
display: inline-block;
vertical-align: - em(6);
margin-right: em(10);
}
.actions-bottom {
@include span-columns(12);
margin-top: em(20);
}

View file

@ -0,0 +1,37 @@
/*
Global Helpers
*/
img.flag {
display: inline-block;
vertical-align: - em(6);
margin-right: em(10);
}
.actions-bottom {
@include span-columns(12);
margin-top: em(20);
}
fieldset {
border: em(2) solid $light-gray;
> br:first-child,
> br:last-child {
display: none;
}
legend {
padding: 0 em(10);
&+br {
display: none;
}
}
blockquote {
border: 0;
padding: 0;
margin: 0;
}
}

View file

@ -7,6 +7,7 @@
background-color: $background-primary; background-color: $background-primary;
height: em(60); height: em(60);
max-height: em(60); max-height: em(60);
nav { nav {
@include outer-container; @include outer-container;
} }
@ -42,6 +43,7 @@ ul.navigation {
padding: em(22); padding: em(22);
float: left; float: left;
border-right: em(1) solid $navbar-border; border-right: em(1) solid $navbar-border;
&:hover, &:hover,
&.active { &.active {
background-color: $navbar-secondary; background-color: $navbar-secondary;
@ -86,6 +88,10 @@ ul.navigation {
li { li {
border-bottom: em(1) solid lighten($navbar-secondary, 10%); border-bottom: em(1) solid lighten($navbar-secondary, 10%);
&:first-child {
border-top: em(1) solid lighten($navbar-secondary, 10%);
}
&:last-child { &:last-child {
border-bottom: none; border-bottom: none;
} }

View file

@ -19,4 +19,16 @@
button, button,
a.button { a.button {
@include button; @include button;
&.tiny {
background-color: transparentize($green, .5);
border-radius: em(14);
height: em(25);
padding: em(1) em(12);
margin: 0 em(10) 0 0;
&:hover {
color: $light-gray;
}
}
} }

View file

@ -0,0 +1,178 @@
/*
Forums
*/
#forums {
/*
Buttons
*/
.controls {
@include span-columns(12);
}
}
/*
Categories
*/
div#categories {
/*
Tables
*/
table.category {
table-layout: auto;
}
.bullet {
width: 10%;
background: image-url('layout/forum-category.png') center center no-repeat;
&.highlight {
background-image: image-url('layout/forum-category-highlight.png');
}
}
.forum {
width: 45%;
padding-right: em(10);
}
.actions {
width: 10%;
text-align: center;
}
.topics,
.posts {
width: 10%;
}
.last {
width: 15%;
}
}
/*
Topics
*/
#topics {
table-layout: auto;
margin-bottom: em(40);
.topic {
width: 55%;
}
.author {
width: 10%;
}
.replies,
.views {
width: 10%;
}
.last {
width: 15%;
}
}
.statistics {
margin: em(20) 0;
h4 {
margin-bottom: 1em;
}
}
#topic {
.controls {
margin-top: em(20);
}
#reply {
display: none;
}
}
/*
Posts
*/
#posts {
@include span-columns(12);
margin-top: em(20);
.post {
@include span-columns(12);
border-top: em(3) solid $light-gray;
padding: em(20) 0;
&:last-child {
border-bottom: em(3) solid $light-gray;
margin-bottom: em(40);
}
.avatar {
@include span-columns(3);
h5 {
text-align: center;
margin-bottom: 1em;
}
.image,
.team {
@include span-columns(12);
text-align: center;
margin-bottom: em(10);
}
.admin {
color: $red;
}
}
.content {
@include span-columns(9);
@include omega;
.text,
.signature {
@include span-columns(12);
padding: em(20) 0;
}
}
.header {
@include span-columns(12);
.time {
@include span-columns(6);
}
.posts {
@include span-columns(6);
text-align: right;
}
}
.actions {
@include span-columns(12);
.user {
@include span-columns(3);
}
.reply {
@include span-columns(9);
@include omega;
}
}
}
}

View file

@ -14,12 +14,26 @@ div.article {
.author { .author {
@include span-columns(6); @include span-columns(6);
a {
font-weight: bold;
}
} }
.actions { .comments {
@include span-columns(6); @include span-columns(6);
@include omega; @include omega;
text-align: right; text-align: right;
.fa {
margin-right: em(10);
}
}
.actions {
@include span-columns(12);
@include omega;
margin-top: em(10);
} }
&:first-child { &:first-child {

View file

@ -1,5 +1,5 @@
class CommentsController < ApplicationController class CommentsController < ApplicationController
before_filter :get_comment, only: [:raw, :edit, :update, :destroy] before_filter :get_comment, only: [:raw, :quote, :edit, :update, :destroy]
respond_to :html, :js respond_to :html, :js
def index def index
@ -47,6 +47,9 @@ class CommentsController < ApplicationController
redirect_to_back redirect_to_back
end end
def quote
end
private private
def get_comment def get_comment

View file

@ -46,13 +46,13 @@ class ForumsController < ApplicationController
def up def up
raise AccessError unless @forum.can_update? cuser raise AccessError unless @forum.can_update? cuser
@forum.move_up :category_id => @forum.category.id @forum.move_up(category_id: @forum.category.id)
redirect_to_back redirect_to_back
end end
def down def down
raise AccessError unless @forum.can_update? cuser raise AccessError unless @forum.can_update? cuser
@forum.move_down :category_id => @forum.category.id @forum.move_down(category_id: @forum.category.id)
redirect_to_back redirect_to_back
end end

View file

@ -0,0 +1,76 @@
module Extra
extend ActiveSupport::Concern
CODING_HTML = 0
CODING_BBCODE = 1
CODING_MARKDOWN = 2
included do
def codings
{
CODING_HTML => "Plain HTML",
CODING_BBCODE => "BBCode",
CODING_MARKDOWN => "Markdown"
}
end
def check_params(params, filter)
(params.instance_of?(Array) ? params : params.keys).each do |key|
return false unless filter.include? key.to_sym
end
return true
end
def error_messages
self.errors.full_messages.uniq
end
def bbcode_to_html(text)
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br>").html_safe
end
def move_up(scope, column = "position")
n = 0
objects = self.class.all(conditions: scope, order: column)
binding.pry
objects.each do |item|
if item.id == id and n > 0
old_position = item.read_attribute(:column)
item.update_attribute(column, objects.fetch(n-1).read_attribute(:column))
objects.fetch(n-1).update_attribute(column, old_position)
end
n = n + 1
end
end
def move_down(scope, column = "position")
n = 0
objects = self.class.all(conditions: scope, order: column)
binding.pry
objects.each do |item|
if item.id == id and n < (objects.length-1)
old_position = item.read_attribute(:column)
item.update_attribute(column, objects.fetch(n+1).read_attribute(:column))
objects.fetch(n+1).update_attribute(column, old_position)
end
n = n + 1
end
end
def can_show? cuser
true
end
def can_create? cuser
true
end
def can_update? cuser
true
end
def can_destroy? cuser
true
end
end
end

View file

@ -13,6 +13,7 @@
class Forum < ActiveRecord::Base class Forum < ActiveRecord::Base
include Extra include Extra
BANS = 8 BANS = 8
TRASH = 12 TRASH = 12

View file

@ -30,7 +30,7 @@ class Topic < ActiveRecord::Base
has_many :posts, :order => "id ASC", :dependent => :destroy has_many :posts, :order => "id ASC", :dependent => :destroy
has_many :view_counts, :as => :viewable, :dependent => :destroy has_many :view_counts, :as => :viewable, :dependent => :destroy
scope :basic, :include => [:latest, {:forum => :forumer}, :user] scope :basic, :include => [:latest, { forum: :forumer }, :user]
scope :ordered, :order => "state DESC, posts.id DESC" scope :ordered, :order => "state DESC, posts.id DESC"
scope :recent, scope :recent,
:conditions => "forumers.id IS NULL AND posts.id = (SELECT id FROM posts AS P WHERE P.topic_id = topics.id ORDER BY id DESC LIMIT 1)", :conditions => "forumers.id IS NULL AND posts.id = (SELECT id FROM posts AS P WHERE P.topic_id = topics.id ORDER BY id DESC LIMIT 1)",

View file

@ -27,6 +27,7 @@ require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_versioned', 'lib', '
class User < ActiveRecord::Base class User < ActiveRecord::Base
include Extra include Extra
VERIFICATION_TIME = 604800 VERIFICATION_TIME = 604800
attr_protected :id, :created_at, :updated_at, :lastvisit, :lastip, :password, :version attr_protected :id, :created_at, :updated_at, :lastvisit, :lastip, :password, :version

View file

@ -1,8 +1,8 @@
<nav id="menu"> <nav id="menu">
<ul class="navigation"> <ul class="navigation">
<li><%= link_to "News", controller: "articles", action: "news_index" %></li> <li><%= active_link_to "News", root_path, active: ["articles", "news_index"] %></li>
<li class="dropdown"> <li class="dropdown">
<%= link_to "Contests", controller: "contests", action: "current" %> <%= active_link_to "Contests", controller: "contests", action: "current" %>
<ul> <ul>
<li><%= link_to "Historical", "/contests" %></li> <li><%= link_to "Historical", "/contests" %></li>
<li><%= link_to "NS1 History", "/contests/historical/NS1" %></li> <li><%= link_to "NS1 History", "/contests/historical/NS1" %></li>
@ -10,27 +10,27 @@
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<%= link_to "Gathers", Gather.last %> <%= active_link_to "Gathers", Gather.last %>
<ul> <ul>
<li><%= link_to "Introduction", article_url(464) %></li> <li><%= link_to "Introduction", article_url(464) %></li>
<li><%= link_to "Archives", "/gathers/" %></li> <li><%= link_to "Archives", "/gathers/" %></li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<%= link_to "Articles", articles_url %> <%= active_link_to "Articles", articles_path %>
<ul> <ul>
<li><%= link_to "NS Movies", movies_url %></li> <li><%= link_to "NS Movies", movies_url %></li>
<li><%= link_to "Files", directory_url(Directory::ROOT) %></li> <li><%= link_to "Files", directory_url(Directory::ROOT) %></li>
</ul> </ul>
</li> </li>
<li class="dropdown"> <li class="dropdown">
<%= link_to "Forums", forums_url %> <%= active_link_to "Forums", forums_path, active: [["forums", "topics"]] %>
<ul> <ul>
<li><%= link_to "Index", forums_url %></li> <li><%= link_to "Index", forums_path %></li>
<li><%= link_to "Rules", "/topics/12" %></li> <li><%= link_to "Rules", "/topics/12" %></li>
</ul> </ul>
</li> </li>
<li><%= link_to "Teams", controller: "teams", action: :index %></li> <li><%= active_link_to "Teams", controller: "teams", action: :index %></li>
<li><%= link_to "Users", controller: "users", action: :index %></li> <li><%= active_link_to "Users", controller: "users", action: :index %></li>
</ul> </ul>
</nav> </nav>

View file

@ -13,14 +13,19 @@
<%= namelink(article.user) %> on <%= longtime article.created_at %> <%= namelink(article.user) %> on <%= longtime article.created_at %>
</div> </div>
<div class="comments">
<%= link_to article do %>
<%= icon 'comments' %> Comments (<%= article.comments.count %>)
<% end %>
</div>
<div class="actions"> <div class="actions">
<% if article.can_update? cuser %> <% if article.can_update? cuser %>
<%= link_to 'Edit', edit_article_path(article) %> | <%= link_to 'Edit', edit_article_path(article), class: 'button tiny' %>
<% end %> <% end %>
<% if article.can_destroy? cuser %> <% if article.can_destroy? cuser %>
<%= link_to 'Destroy', article, confirm: 'Are you sure?', method: :delete %> | <%= link_to 'Destroy', article, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
<% end %> <% end %>
<%= link_to "History", article_versions_path(article) %> | <%= link_to "History", article_versions_path(article), class: 'button tiny' %>
<%= link_to "Comments: #{article.comments.count}", article %>
</div> </div>
</div> </div>

View file

@ -11,7 +11,7 @@
<div class="controls"> <div class="controls">
<% if cuser %> <% if cuser %>
[ [
<%= link_to_function 'Q', "QuoteText('comments', #{comment.id}, '#{comment.user}')" %> <%= link_to_function 'Q', "QuoteText(#{comment.id}, 'comments')" %>
<% if comment.can_update? cuser %> <% if comment.can_update? cuser %>
<%= link_to 'E', edit_comment_path(comment) %> <%= link_to 'E', edit_comment_path(comment) %>
<% end %> <% end %>

View file

@ -1,4 +1,4 @@
<div class="comment-form"> <div id="reply" class="comment-form">
<h5>New comment</h5> <h5>New comment</h5>
<% if cuser %> <% if cuser %>
@ -11,7 +11,7 @@
<%= f.hidden_field :commentable_id %> <%= f.hidden_field :commentable_id %>
<%= f.hidden_field :commentable_type %> <%= f.hidden_field :commentable_type %>
<div class="fields"> <div class="fields">
<%= f.text_area :text, rows: 5, cols: 40, id: "textArea" %> <%= f.text_area :text, rows: 5 %>
</div> </div>
<div class="controls"> <div class="controls">
<%= f.submit 'Post Comment' %> <%= f.submit 'Post Comment' %>

View file

@ -0,0 +1 @@
$("#reply textarea").append("[quote=<%= @comment.user %>]<%= escape_javascript(@comment.text) %>[/quote]\n");

View file

@ -0,0 +1,11 @@
<div class="controls">
<% if forum.topics.build.can_create? cuser %>
<%= link_to 'New Topic', new_topic_url(id: forum.id), class: 'button' %>
<% end %>
<% if forum.can_update? cuser %>
<%= link_to 'Edit Forum', edit_forum_path(forum), class: 'button' %>
<% end %>
<% if forum.can_destroy? cuser %>
<%= link_to 'Destroy Forum', forum, class: 'button', confirm: 'Are you sure?', method: :delete %>
<% end %>
</div>

View file

@ -1,46 +1,44 @@
<br /> <div id="categories">
<div class="forums">
<% @categories.each do |cat| %> <% @categories.each do |cat| %>
<% forums = cuser ? cat.forums.available_to(cuser, Forumer::ACCESS_READ).ordered : cat.forums.public.ordered %> <% forums = cuser ? cat.forums.available_to(cuser, Forumer::ACCESS_READ).ordered : cat.forums.public.ordered %>
<% next if forums.length == 0 %> <% next if forums.length == 0 %>
<h3><%=h cat.name %></h3>
<div class="category"> <div class="category">
<table class="body"> <table class="category">
<tr> <tr>
<th colspan="5" class="header"> <th colspan="2" class="forums">Forums</th>
<%= h cat.to_s %> <th class="actions"></th>
</th> <th class="topics">Topics</th>
</tr> <th class="posts">Posts</th>
<tr> <th class="last">Last Post</th>
<th colspan="2">Forums</th>
<th class="center" width="10%">Topics</th>
<th class="center" width="10%">Posts</th>
<th class="center" width="15%">Last Post</th>
</tr> </tr>
<% forums.each do |forum| %> <% forums.each do |forum| %>
<tr> <tr>
<td class="bullet <%= "hl" if cuser and !forum.read_by? cuser %>">&nbsp;</td> <td class="bullet <%= "highlight" if cuser and !forum.read_by?(cuser) %>"></td>
<td class="forum"> <td class="forum">
<div class="left"> <h5><%= namelink(forum) %></h5>
<h3 class="desc">
<%= namelink forum %>
</h3>
<%= forum.description %> <%= forum.description %>
</div> </td>
<div class="right minitext"> <td class="actions">
<% if forum.can_update? cuser %> <% if forum.can_update? cuser %>
<%= link_to "Up", :action => "up", :id => forum %><br /> <%= link_to action: "up", id: forum do %>
<%= link_to "Down", :action => "down", :id => forum %> <% icon 'arrow-up' %>
<% end %>
<%= link_to action: "down", id: forum do %>
<% icon 'arrow-down' %>
<% end %>
<% end %> <% end %>
</div>
<div class="clear"></div>
</td> </td>
<td class="numbers"><%= forum.topics.count %></td> <td class="topics"><%= forum.topics.count %></td>
<td class="numbers"><%= forum.posts.count %></td> <td class="posts"><%= forum.posts.count %></td>
<td> <td class="last">
<% if forum.posts.last %> <% if forum.posts.last %>
<%= link_to raw("#{h forum.posts.last.user} <br />#{shortdate forum.posts.last.created_at}"), lastpost(forum.posts.last.topic) %> <%= link_to lastpost(forum.posts.last.topic) do %>
<%=h forum.posts.last.user %><br>
<%= shortdate(forum.posts.last.created_at) %>
<% end %>
<% end %> <% end %>
</td> </td>
</tr> </tr>
@ -48,28 +46,21 @@
</table> </table>
</div> </div>
<% end %> <% end %>
</div>
<div class="category"> <div class="statistics">
<table class="body"> <h4>Statistics</h4>
<tr> <p>
<th colspan="5" class="header"> We have total of <strong><%= Post.count %></strong> posts,
Statistics <strong><%= Topic.count %></strong> topics, and <strong><%= User.count %></strong> users.
</th> </p>
</tr> <p>
<tr>
<td colspan="5" class="center">
We have total of <b><%= Post.count %></b> posts,
<b><%= Topic.count %></b> topics, and <b><%= User.count %></b> users.
Our newest member is <%= namelink User.last %> and most active member is <%= namelink User.posts_stats.first %>. Our newest member is <%= namelink User.last %> and most active member is <%= namelink User.posts_stats.first %>.
</td> </p>
</tr>
</table>
</div>
</div> </div>
<% if Forum.new.can_create? cuser %> <% if Forum.new.can_create? cuser %>
<p> <p>
<%= link_to 'New forum', new_forum_path %> <%= link_to 'New forum', new_forum_path, class: "button" %>
</p> </p>
<% end %> <% end %>

View file

@ -1,75 +1,51 @@
<p> <div class="breadcrumbs">
<%= link_to "Forums", :action => "index" %> &#187; <%= namelink @forum %> <%= link_to "Forums", action: "index" %> <%= icon 'chevron-right' %> <%= namelink @forum %>
</p> </div>
<p> <%= render partial: 'controls', locals: { forum: @forum } %>
<% if @forum.topics.build.can_create? cuser %>
<%= link_to 'New Topic', new_topic_url(:id => @forum.id) %>
<% end %>
<% if @forum.can_update? cuser %>
| <%= link_to 'Edit Forum', edit_forum_path(@forum) %>
<% end %>
<% if @forum.can_destroy? cuser %>
| <%= link_to 'Destroy Forum', @forum, :confirm => 'Are you sure?', :method => :delete %>
<% end %>
</p>
<h2><%=h @forum.title %></h2>
<div class="forums"> <table id="topics">
<div class="category">
<table class="body">
<tr> <tr>
<th colspan="5" class="header"> <th class="topic">Topic</th>
<%= h @forum.title %> <th class="author">Author</th>
</th> <th class="replies">Replies</th>
</tr> <th class="views">Views</th>
<tr> <th class="last">Last Post</th>
<th width="50%">Topic</th>
<th class="center" width="15%">Author</th>
<th class="center" width="5%">Replies</th>
<th class="center" width="5%">Views</th>
<th class="center" width="15%">Last Post</th>
</tr> </tr>
<% @forum.topics.basic.ordered.each do |topic| %> <% @forum.topics.basic.ordered.each do |topic| %>
<tr> <tr>
<td> <td>
<h3> <h5>
<% if topic.state == Topic::STATE_STICKY %> <% if topic.state == Topic::STATE_STICKY %>
<b>Sticky: </b> <b>Sticky: </b>
<% elsif topic.lock %> <% elsif topic.lock %>
<b>Locked: </b> <b>Locked: </b>
<% end %> <% end %>
<%= link_to (h topic), topic, :class => ((cuser and !topic.read_by? cuser) ? "red" : "") %>
<%= link_to (h topic), topic, class: ((cuser and !topic.read_by? cuser) ? "unread" : "read") %>
</h5>
<% if topic.posts.count > Topic::POSTS_PAGE %> <% if topic.posts.count > Topic::POSTS_PAGE %>
[ Page:
<% (1..((topic.posts.count/Topic::POSTS_PAGE).ceil+1)).to_a.each do |page| %> <% (1..((topic.posts.count/Topic::POSTS_PAGE).ceil + 1)).to_a.each do |page| %>
<%= ", " unless page == 1 %> <%= ", " unless page == 1 %>
<%= link_to page, topic_url(topic, :page => page) %> <%= link_to page, topic_url(topic, page: page) %>
<% end %> <% end %>
]
<% end %> <% end %>
</h3>
</td> </td>
<td><%= namelink topic.user %></td> <td><%= namelink(topic.user) %></td>
<td><%= h topic.posts.count-1 %></td> <td><%=h topic.posts.count-1 %></td>
<td><%= h topic.view_count %></td> <td><%=h topic.view_count %></td>
<td> <td>
<%= link_to raw("#{h topic.posts.last.user} <br />#{shortdate topic.posts.last.created_at}"), lastpost(topic) %> <%= link_to lastpost(topic) do %>
<%=h topic.posts.last.user %><br>
<%= shortdate(topic.posts.last.created_at) %>
<% end %>
</td> </td>
</tr> </tr>
<% end %> <% end %>
</table> </table>
</div>
<p> <%= render partial: 'controls', locals: { forum: @forum } %>
<% if @forum.topics.build.can_create? cuser %>
<%= link_to 'New Topic', new_topic_url(:id => @forum.id) %>
<% end %>
<% if @forum.can_update? cuser %>
| <%= link_to 'Edit Forum', edit_forum_path(@forum) %>
<% end %>
<% if @forum.can_destroy? cuser %>
| <%= link_to 'Destroy Forum', @forum, :confirm => 'Are you sure?', :method => :delete %>
<% end %>
</p>
</div>

View file

@ -1,69 +1,58 @@
<% if n > 0 or n == -1 %> <div id="post_<%= post.id %>" class="post">
<tr> <div class="avatar" rowspan="2">
<th class="seperator" colspan="2"> <h5>
</th> <%= link_to post.user, post.user, class: ("admin" if post.user.admin?) %>
</tr> </h5>
<% end %>
<tr> <div class="image">
<td class="avatar" rowspan="2"> <%= image_tag post.user.profile.avatar.url %>
<h3 class="center"> </div>
<%= link_to post.user, post.user, :class => (post.user.admin? ? "red" : "") %>
</h3>
<%= image_tag post.user.profile.avatar.url, :class => "centered" %>
<% if post.user.team %> <% if post.user.team %>
<p class="center">
<%= namelink post.user.team %> <%= namelink post.user.team %>
</p>
<% end %> <% end %>
<%= cascade post.user, [["Posts", "posts.count"], "from", "joined"] %>
</td>
<th class="header"> <%= cascade post.user, [["Posts", "posts.count"], "from", "joined"] %>
<div class="left"> </div>
<div class="content">
<div class="header">
<div class="time">
<a name="post_<%= post.id %>"> <a name="post_<%= post.id %>">
<%= longtime post.created_at %> <%= longtime(post.created_at) %>
</a> </a>
</div> </div>
<div class="posts">
<div class="right"> <%= link_to "##{post.number(@posts, n)}", "#post_#{post.id}" %>
<%= post.number @posts, n %> </div>
</div> </div>
<div class="clear"></div> <div class="text">
</th>
</tr>
<tr>
<td class="text" id="post_<%= post.id %>">
<%= post.text_parsed.html_safe %> <%= post.text_parsed.html_safe %>
</td>
</tr>
<tr>
<td class="actions center">
<%= link_to "Send PM", :controller => "messages", :action => "new", :id => "User", :id2 => post.user %>
</td>
<td class="signature">
<div class="left">
<%= raw post.user.profile.signature_parsed if post.user.profile.signature_parsed %>
</div> </div>
<div class="signature">
<%= post.user.profile.signature_parsed.html_safe if post.user.profile.signature_parsed %>
</div>
</div>
<div class="actions">
<div class="user">
<%= link_to "Send PM", { controller: "messages", action: "new", id: "User", id2: post.user }, class: 'button tiny' %>
</div>
<div class="reply">
<div class="right"> <div class="right">
<% if post.topic.posts.build.can_create? cuser %> <% if post.topic.posts.build.can_create? cuser %>
<%= link_to_function 'QuoteReply', "QuoteText(#{post.id}); $('tr#reply').fadeIn('slow');" %> <%= link_to_function 'Quote Reply', "QuoteText(#{post.id}); $('#reply').fadeIn('slow')", class: 'button tiny' %>
<% end %> <% end %>
<% if post.can_update? cuser %> <% if post.can_update? cuser %>
<%= link_to 'Edit', edit_post_path(post) %> <%= link_to 'Edit', edit_post_path(post), class: 'button tiny' %>
<% end %> <% end %>
<% if post.can_destroy? cuser %> <% if post.can_destroy? cuser %>
<%= link_to 'Delete', post, :confirm => 'Are you sure?', :method => :delete %> <%= link_to 'Delete', post, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
<% end %> <% end %>
</div> </div>
</div>
<div class="clear"></div> </div>
</td> </div>
</tr>

View file

@ -1,2 +1,2 @@
$("tr#reply").hide(); $("#reply").find("textarea").val("").end().hide();
$("tbody#posts").append("<%= escape_javascript(render(:partial => "post", :locals => {:post => @post, :n => -1})) %>"); $("#posts").append("<%= escape_javascript(render(partial: 'post', locals: { post: @post, n: -1 })) %>");

View file

@ -1 +1 @@
$("tr#reply textarea").append("[quote=<%= @post.user %>]<%= escape_javascript(@post.text) %>[/quote]\n"); $("#reply textarea").append("[quote=<%= @post.user %>]<%= escape_javascript(@post.text) %>[/quote]\n");

View file

@ -0,0 +1,7 @@
<div class="breadcrumbs">
<%= link_to "Forums", forums_url %>
<%= icon 'chevron-right' %>
<%= namelink topic.forum %>
<%= icon 'chevron-right' %>
<%= namelink topic %>
</div>

View file

@ -1,96 +1,70 @@
<p> <div id="topic">
<%= link_to "Forums", forums_url %> &#187; <%= namelink @topic.forum %> &#187; <%= namelink @topic %> <%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
</p>
<table id="topic"> <h2><%= namelink @topic %></h2>
<thead>
<tr> <% if @posts.count > Topic::POSTS_PAGE %>
<th colspan="2"> <%= will_paginate @posts %>
<div class="left">
<%= namelink @topic %>
<% if @posts.length > Topic::POSTS_PAGE %>
[<%= will_paginate @posts %>]
<% end %> <% end %>
</div>
<div class="right"> <div class="controls">
<% if @newpost.can_create? cuser %> <% if @newpost.can_create? cuser %>
<%= link_to 'Reply', new_post_path(@newpost, :id => @topic) %> | <%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
<% end %> <% end %>
<% if @topic.can_update? cuser %> <% if @topic.can_update? cuser %>
<%= link_to 'Edit', edit_topic_path(@topic) %> <%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
<% end %> <% end %>
</div> </div>
<div class="clear"></div> <div id="posts">
</th> <% @posts.each_with_index do |post, n| %>
</tr> <%= render partial: "posts/post", locals: { post: post, n: n } %>
</thead> <% end %>
<tbody id="posts">
<% n = 0; @posts.each do |post| %>
<%= render :partial => "posts/post", :locals => {:post => post, :n => n} %>
<% n = n + 1 end %>
<% if @newpost.errors.count > 0 %> <% if @newpost.errors.count > 0 %>
<tr>
<td colspan="2" class="center">
<% @newpost.error_messages.each do |m| %> <% @newpost.error_messages.each do |m| %>
<%= h m %><br /> <%= h m %><br>
<% end %> <% end %>
</td>
</tr>
<% end %> <% end %>
</tbody> </div>
<tfoot> <div id="reply">
<tr id="reply"> <h5>New Reply</h5>
<td colspan="2">
<div class="centered center" style="width: 583px;"> <%= form_for(@newpost, remote: true, html: { class: 'square' }) do |f| %>
<%= form_for(@newpost, :remote => true) do |f| %>
<%= f.error_messages %> <%= f.error_messages %>
<%= f.hidden_field :topic_id %> <%= f.hidden_field :topic_id %>
<p> <div class="fields horizontal">
<%= f.text_area :text, :rows => 13, :cols => 70, :id => "textArea" %> <%= f.label "Enter your post text:" %>
</p> <%= f.text_area :text, rows: 10 %>
<p> </div>
<div class="controls horizontal">
<%= f.submit 'Post Message' %> <%= f.submit 'Post Message' %>
</p> </div>
<% end %> <% end %>
</div> </div>
</td>
</tr>
<tr>
<th colspan="2">
<div class="left minitext">
<%= will_paginate @posts %> <%= will_paginate @posts %>
</div>
<div class="right minitext"> <div class="right minitext">
<% if @newpost.can_create? cuser %> <% if @newpost.can_create? cuser %>
<%= link_to_function 'Fast Reply', "$('tr#reply').fadeIn('slow');" %> | <%= link_to_function 'Fast Reply', "$('#reply').fadeIn('slow')", class: 'button' %>
<%= link_to 'Reply', new_post_path(@newpost, :id => @topic) %> | <%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
<% end %> <% end %>
<% if @topic.can_update? cuser %> <% if @topic.can_update? cuser %>
<%= link_to 'Edit', edit_topic_path(@topic) %> <%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
<% end %> <% end %>
<% if @lock.new_record? and @lock.can_create? cuser %> <% if @lock.new_record? and @lock.can_create? cuser %>
<%= form_for @lock, :html => {:style => "display:inline"} do |f| %> <%= form_for @lock do |f| %>
<%= f.hidden_field :lockable_type %> <%= f.hidden_field :lockable_type %>
<%= f.hidden_field :lockable_id %> <%= f.hidden_field :lockable_id %>
| <%= link_to_function "Lock", "this.parentNode.submit()" %> <%= link_to_function "Lock", "this.parentNode.submit()", class: 'button' %>
<% end %> <% end %>
<% elsif @lock.can_destroy? cuser %> <% elsif @lock.can_destroy? cuser %>
| <%= link_to 'Unlock', @lock, :confirm => 'Are you sure?', :method => :delete %> <%= link_to 'Unlock', @lock, class: 'button', confirm: 'Are you sure?', method: :delete %>
<% end %> <% end %>
</div> </div>
<div class="clear"></div> <%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
</th> </div>
</tr>
</tfoot>
</table>
<p>
<%= link_to "Forums", forums_url %> &#187; <%= namelink @topic.forum %> &#187; <%= namelink @topic %>
</p>

View file

@ -10,7 +10,7 @@ module Ensl
# -- all .rb files in that directory are automatically loaded. # -- all .rb files in that directory are automatically loaded.
# Custom directories with classes and modules you want to be autoloadable. # Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += Dir["#{config.root}/app/services/**/"] config.autoload_paths += Dir["#{config.root}/app/services/**/", "#{config.root}/app/models/concerns/"]
# Only load the plugins named here, in the order given (default is alphabetical). # Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins nowt explicitly named. # :all can be used as a placeholder for all plugins nowt explicitly named.

View file

@ -5,7 +5,7 @@ set :deploy_via, :remote_cache
set :pty, true set :pty, true
set :scm, :git set :scm, :git
set :repo_url, 'git@github.com:ENSL/ensl.org.git' set :repo_url, 'https://github.com/ENSL/ensl.org.git'
set :keep_releases, 10 set :keep_releases, 10
set :rbenv_type, :user set :rbenv_type, :user

View file

@ -1,7 +1,6 @@
require File.expand_path('../application', __FILE__) require File.expand_path('../application', __FILE__)
require 'verification' require 'verification'
require 'exceptions' require 'exceptions'
require 'extra'
ActiveSupport::Deprecation.silenced = true ActiveSupport::Deprecation.silenced = true
Ensl::Application.initialize! Ensl::Application.initialize!

View file

@ -13,6 +13,9 @@ Ensl::Application.routes.draw do
resources :categories resources :categories
resources :options resources :options
resources :polls resources :polls
match 'comments/quote'
resources :comments resources :comments
resources :shoutmsgs resources :shoutmsgs
resources :teamers resources :teamers
@ -23,6 +26,10 @@ Ensl::Application.routes.draw do
resources :groupers resources :groupers
resources :forumers resources :forumers
resources :topics resources :topics
match 'forums/up'
match 'forums/down'
resources :forums resources :forums
resources :users resources :users
resources :locks resources :locks
@ -46,6 +53,9 @@ Ensl::Application.routes.draw do
resources :bans resources :bans
resources :tweets resources :tweets
resources :issues resources :issues
match 'posts/quote'
resources :posts resources :posts
resources :brackets resources :brackets
@ -74,9 +84,6 @@ Ensl::Application.routes.draw do
match 'directories', to: "directories#show", id: 1 match 'directories', to: "directories#show", id: 1
match 'forums/up'
match 'forums/down'
match 'gathers/refresh' match 'gathers/refresh'
match 'gathers/latest/:game', to: "gathers#latest", via: :get match 'gathers/latest/:game', to: "gathers#latest", via: :get
match 'gather', to: "gathers#latest", game: "ns2", via: :get match 'gather', to: "gathers#latest", game: "ns2", via: :get
@ -101,8 +108,6 @@ Ensl::Application.routes.draw do
match 'users/logout' match 'users/logout'
match 'users/login' match 'users/login'
match 'posts/quote'
match 'users/agenda' match 'users/agenda'
match 'users/login' match 'users/login'
match 'users/logout' match 'users/logout'

View file

@ -1,66 +0,0 @@
module Extra
CODING_HTML = 0
CODING_BBCODE = 1
CODING_MARKDOWN = 2
def check_params params, filter
(params.instance_of?(Array) ? params : params.keys).each do |key|
return false unless filter.include? key.to_sym
end
return true
end
def error_messages
self.errors.full_messages.uniq
end
def codings
{CODING_HTML => "Plain HTML", CODING_BBCODE => "BBCode", CODING_MARKDOWN => "Markdown"}
end
def bbcode_to_html(text)
Sanitize.clean(text.to_s).bbcode_to_html.gsub(/\n|\r\n/, "<br />").html_safe
end
def move_up scope, column = "position"
n = 0
objects = self.class.all :conditions => scope, :order => column
objects.each do |item|
if item.id == id and n > 0
old_position = item.read_attribute :column
item.update_attribute column, objects.fetch(n-1).read_attribute(:column)
objects.fetch(n-1).update_attribute column, old_position
end
n = n + 1
end
end
def move_down scope, column = "position"
n = 0
objects = self.class.all :conditions => scope, :order => column
objects.each do |item|
if item.id == id and n < (objects.length-1)
old_position = item.read_attribute :column
item.update_attribute column, objects.fetch(n+1).read_attribute(:column)
objects.fetch(n+1).update_attribute column, old_position
end
n = n + 1
end
end
def can_show? cuser
true
end
def can_create? cuser
true
end
def can_update? cuser
true
end
def can_destroy? cuser
true
end
end