mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 04:21:36 +00:00
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:
parent
cf8a92f628
commit
775f5682a4
42 changed files with 658 additions and 386 deletions
5
Gemfile
5
Gemfile
|
@ -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
|
||||||
|
|
13
Gemfile.lock
13
Gemfile.lock
|
@ -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)
|
||||||
|
|
BIN
app/assets/images/layout/forum-category-highlight.png
Normal file
BIN
app/assets/images/layout/forum-category-highlight.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
app/assets/images/layout/forum-category.png
Normal file
BIN
app/assets/images/layout/forum-category.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.2 KiB |
BIN
app/assets/images/logo-icon.png
Normal file
BIN
app/assets/images/logo-icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 275 KiB |
|
@ -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"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
|
|
@ -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";
|
||||||
|
|
16
app/assets/stylesheets/components/_breadcrumbs.scss
Normal file
16
app/assets/stylesheets/components/_breadcrumbs.scss
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
/*
|
||||||
|
Breadcrumbs
|
||||||
|
*/
|
||||||
|
|
||||||
|
.breadcrumbs {
|
||||||
|
@include span-columns(12);
|
||||||
|
margin-bottom: em(20);
|
||||||
|
|
||||||
|
a {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fa {
|
||||||
|
margin: 0 em(10);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
8
app/assets/stylesheets/components/_pagination.scss
Normal file
8
app/assets/stylesheets/components/_pagination.scss
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
/*
|
||||||
|
Pagination
|
||||||
|
*/
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
@include span-columns(12);
|
||||||
|
margin: em(20) 0;
|
||||||
|
}
|
|
@ -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);
|
|
||||||
}
|
|
37
app/assets/stylesheets/layout/_helpers.scss
Normal file
37
app/assets/stylesheets/layout/_helpers.scss
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
178
app/assets/stylesheets/pages/_forums.scss
Normal file
178
app/assets/stylesheets/pages/_forums.scss
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
||||||
|
|
76
app/models/concerns/extra.rb
Normal file
76
app/models/concerns/extra.rb
Normal 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
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
class Forum < ActiveRecord::Base
|
class Forum < ActiveRecord::Base
|
||||||
include Extra
|
include Extra
|
||||||
|
|
||||||
BANS = 8
|
BANS = 8
|
||||||
TRASH = 12
|
TRASH = 12
|
||||||
|
|
||||||
|
|
|
@ -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)",
|
||||||
|
@ -39,7 +39,7 @@ class Topic < ActiveRecord::Base
|
||||||
scope :latest_page,
|
scope :latest_page,
|
||||||
lambda { |page| {:limit => "#{(page-1)*LATEST_PER_PAGE}, #{(page-1)*LATEST_PER_PAGE+LATEST_PER_PAGE}"} }
|
lambda { |page| {:limit => "#{(page-1)*LATEST_PER_PAGE}, #{(page-1)*LATEST_PER_PAGE+LATEST_PER_PAGE}"} }
|
||||||
|
|
||||||
validates_presence_of :user_id, :forum_id
|
validates_presence_of :user_id, :forum_id
|
||||||
validates_length_of :title, :in => 1..50
|
validates_length_of :title, :in => 1..50
|
||||||
validates_length_of :first_post, :in => 1..10000, :on => :create
|
validates_length_of :first_post, :in => 1..10000, :on => :create
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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 %>
|
||||||
|
|
|
@ -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' %>
|
||||||
|
|
1
app/views/comments/quote.js.erb
Normal file
1
app/views/comments/quote.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$("#reply textarea").append("[quote=<%= @comment.user %>]<%= escape_javascript(@comment.text) %>[/quote]\n");
|
11
app/views/forums/_controls.html.erb
Normal file
11
app/views/forums/_controls.html.erb
Normal 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>
|
|
@ -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 %>"> </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">
|
<%= forum.description %>
|
||||||
<%= namelink forum %>
|
|
||||||
</h3>
|
|
||||||
<%= forum.description %>
|
|
||||||
</div>
|
|
||||||
<div class="right minitext">
|
|
||||||
<% if forum.can_update? cuser %>
|
|
||||||
<%= link_to "Up", :action => "up", :id => forum %><br />
|
|
||||||
<%= link_to "Down", :action => "down", :id => forum %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
<div class="clear"></div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="numbers"><%= forum.topics.count %></td>
|
<td class="actions">
|
||||||
<td class="numbers"><%= forum.posts.count %></td>
|
<% if forum.can_update? cuser %>
|
||||||
<td>
|
<%= link_to action: "up", id: forum do %>
|
||||||
|
<% icon 'arrow-up' %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to action: "down", id: forum do %>
|
||||||
|
<% icon 'arrow-down' %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td class="topics"><%= forum.topics.count %></td>
|
||||||
|
<td class="posts"><%= forum.posts.count %></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>
|
||||||
|
Our newest member is <%= namelink User.last %> and most active member is <%= namelink User.posts_stats.first %>.
|
||||||
<tr>
|
</p>
|
||||||
<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 %>.
|
|
||||||
</td>
|
|
||||||
</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 %>
|
||||||
|
|
|
@ -1,75 +1,51 @@
|
||||||
<p>
|
<div class="breadcrumbs">
|
||||||
<%= link_to "Forums", :action => "index" %> » <%= namelink @forum %>
|
<%= link_to "Forums", action: "index" %> <%= icon 'chevron-right' %> <%= namelink @forum %>
|
||||||
</p>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<% 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 class="forums">
|
|
||||||
<div class="category">
|
|
||||||
<table class="body">
|
|
||||||
<tr>
|
|
||||||
<th colspan="5" class="header">
|
|
||||||
<%= h @forum.title %>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<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>
|
|
||||||
<% @forum.topics.basic.ordered.each do |topic| %>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<h3>
|
|
||||||
<% if topic.state == Topic::STATE_STICKY %>
|
|
||||||
<b>Sticky: </b>
|
|
||||||
<% elsif topic.lock %>
|
|
||||||
<b>Locked: </b>
|
|
||||||
<% end %>
|
|
||||||
<%= link_to (h topic), topic, :class => ((cuser and !topic.read_by? cuser) ? "red" : "") %>
|
|
||||||
<% if topic.posts.count > Topic::POSTS_PAGE %>
|
|
||||||
[
|
|
||||||
<% (1..((topic.posts.count/Topic::POSTS_PAGE).ceil+1)).to_a.each do |page| %>
|
|
||||||
<%= ", " unless page == 1 %>
|
|
||||||
<%= link_to page, topic_url(topic, :page => page) %>
|
|
||||||
<% end %>
|
|
||||||
]
|
|
||||||
<% end %>
|
|
||||||
</h3>
|
|
||||||
</td>
|
|
||||||
<td><%= namelink topic.user %></td>
|
|
||||||
<td><%= h topic.posts.count-1 %></td>
|
|
||||||
<td><%= h topic.view_count %></td>
|
|
||||||
<td>
|
|
||||||
<%= link_to raw("#{h topic.posts.last.user} <br />#{shortdate topic.posts.last.created_at}"), lastpost(topic) %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
<% 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>
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'controls', locals: { forum: @forum } %>
|
||||||
|
|
||||||
|
<h2><%=h @forum.title %></h2>
|
||||||
|
|
||||||
|
<table id="topics">
|
||||||
|
<tr>
|
||||||
|
<th class="topic">Topic</th>
|
||||||
|
<th class="author">Author</th>
|
||||||
|
<th class="replies">Replies</th>
|
||||||
|
<th class="views">Views</th>
|
||||||
|
<th class="last">Last Post</th>
|
||||||
|
</tr>
|
||||||
|
<% @forum.topics.basic.ordered.each do |topic| %>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h5>
|
||||||
|
<% if topic.state == Topic::STATE_STICKY %>
|
||||||
|
<b>Sticky: </b>
|
||||||
|
<% elsif topic.lock %>
|
||||||
|
<b>Locked: </b>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= link_to (h topic), topic, class: ((cuser and !topic.read_by? cuser) ? "unread" : "read") %>
|
||||||
|
</h5>
|
||||||
|
|
||||||
|
<% if topic.posts.count > Topic::POSTS_PAGE %>
|
||||||
|
Page:
|
||||||
|
<% (1..((topic.posts.count/Topic::POSTS_PAGE).ceil + 1)).to_a.each do |page| %>
|
||||||
|
<%= ", " unless page == 1 %>
|
||||||
|
<%= link_to page, topic_url(topic, page: page) %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td><%= namelink(topic.user) %></td>
|
||||||
|
<td><%=h topic.posts.count-1 %></td>
|
||||||
|
<td><%=h topic.view_count %></td>
|
||||||
|
<td>
|
||||||
|
<%= link_to lastpost(topic) do %>
|
||||||
|
<%=h topic.posts.last.user %><br>
|
||||||
|
<%= shortdate(topic.posts.last.created_at) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<%= render partial: 'controls', locals: { forum: @forum } %>
|
||||||
|
|
|
@ -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"] %>
|
<%= cascade post.user, [["Posts", "posts.count"], "from", "joined"] %>
|
||||||
</td>
|
</div>
|
||||||
|
|
||||||
<th class="header">
|
<div class="content">
|
||||||
<div class="left">
|
<div class="header">
|
||||||
<a name="post_<%= post.id %>">
|
<div class="time">
|
||||||
<%= longtime post.created_at %>
|
<a name="post_<%= post.id %>">
|
||||||
</a>
|
<%= longtime(post.created_at) %>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="posts">
|
||||||
|
<%= link_to "##{post.number(@posts, n)}", "#post_#{post.id}" %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="right">
|
<div class="text">
|
||||||
<%= post.number @posts, n %>
|
<%= post.text_parsed.html_safe %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="signature">
|
||||||
</th>
|
<%= post.user.profile.signature_parsed.html_safe if post.user.profile.signature_parsed %>
|
||||||
</tr>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<tr>
|
<div class="actions">
|
||||||
<td class="text" id="post_<%= post.id %>">
|
<div class="user">
|
||||||
<%= post.text_parsed.html_safe %>
|
<%= link_to "Send PM", { controller: "messages", action: "new", id: "User", id2: post.user }, class: 'button tiny' %>
|
||||||
</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="right">
|
<div class="reply">
|
||||||
<% if post.topic.posts.build.can_create? cuser %>
|
<div class="right">
|
||||||
<%= link_to_function 'QuoteReply', "QuoteText(#{post.id}); $('tr#reply').fadeIn('slow');" %>
|
<% if post.topic.posts.build.can_create? cuser %>
|
||||||
<% end %>
|
<%= link_to_function 'Quote Reply', "QuoteText(#{post.id}); $('#reply').fadeIn('slow')", class: 'button tiny' %>
|
||||||
<% if post.can_update? cuser %>
|
<% end %>
|
||||||
<%= link_to 'Edit', edit_post_path(post) %>
|
<% if post.can_update? cuser %>
|
||||||
<% end %>
|
<%= link_to 'Edit', edit_post_path(post), class: 'button tiny' %>
|
||||||
<% if post.can_destroy? cuser %>
|
<% end %>
|
||||||
<%= link_to 'Delete', post, :confirm => 'Are you sure?', :method => :delete %>
|
<% if post.can_destroy? cuser %>
|
||||||
<% end %>
|
<%= link_to 'Delete', post, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<div class="clear"></div>
|
</div>
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
|
@ -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 })) %>");
|
||||||
|
|
|
@ -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");
|
||||||
|
|
7
app/views/topics/_breadcrumbs.html.erb
Normal file
7
app/views/topics/_breadcrumbs.html.erb
Normal 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>
|
|
@ -1,96 +1,70 @@
|
||||||
<p>
|
<div id="topic">
|
||||||
<%= link_to "Forums", forums_url %> » <%= namelink @topic.forum %> » <%= namelink @topic %>
|
<%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
|
||||||
</p>
|
|
||||||
|
|
||||||
<table id="topic">
|
<h2><%= namelink @topic %></h2>
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="2">
|
|
||||||
<div class="left">
|
|
||||||
<%= namelink @topic %>
|
|
||||||
<% if @posts.length > Topic::POSTS_PAGE %>
|
|
||||||
[<%= will_paginate @posts %>]
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="right">
|
<% if @posts.count > Topic::POSTS_PAGE %>
|
||||||
<% if @newpost.can_create? cuser %>
|
<%= will_paginate @posts %>
|
||||||
<%= link_to 'Reply', new_post_path(@newpost, :id => @topic) %> |
|
<% end %>
|
||||||
<% end %>
|
|
||||||
<% if @topic.can_update? cuser %>
|
|
||||||
<%= link_to 'Edit', edit_topic_path(@topic) %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="controls">
|
||||||
</th>
|
<% if @newpost.can_create? cuser %>
|
||||||
</tr>
|
<%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
|
||||||
</thead>
|
<% end %>
|
||||||
|
<% if @topic.can_update? cuser %>
|
||||||
|
<%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<tbody id="posts">
|
<div id="posts">
|
||||||
<% n = 0; @posts.each do |post| %>
|
<% @posts.each_with_index do |post, n| %>
|
||||||
<%= render :partial => "posts/post", :locals => {:post => post, :n => n} %>
|
<%= render partial: "posts/post", locals: { post: post, n: n } %>
|
||||||
<% n = n + 1 end %>
|
<% end %>
|
||||||
<% if @newpost.errors.count > 0 %>
|
|
||||||
<tr>
|
<% if @newpost.errors.count > 0 %>
|
||||||
<td colspan="2" class="center">
|
<% @newpost.error_messages.each do |m| %>
|
||||||
<% @newpost.error_messages.each do |m| %>
|
<%= h m %><br>
|
||||||
<%= h m %><br />
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</tbody>
|
<% end %>
|
||||||
|
</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) do |f| %>
|
|
||||||
<%= f.error_messages %>
|
|
||||||
<%= f.hidden_field :topic_id %>
|
|
||||||
<p>
|
|
||||||
<%= f.text_area :text, :rows => 13, :cols => 70, :id => "textArea" %>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<%= f.submit 'Post Message' %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<%= form_for(@newpost, remote: true, html: { class: 'square' }) do |f| %>
|
||||||
<th colspan="2">
|
<%= f.error_messages %>
|
||||||
<div class="left minitext">
|
<%= f.hidden_field :topic_id %>
|
||||||
<%= will_paginate @posts %>
|
<div class="fields horizontal">
|
||||||
</div>
|
<%= f.label "Enter your post text:" %>
|
||||||
|
<%= f.text_area :text, rows: 10 %>
|
||||||
<div class="right minitext">
|
|
||||||
<% if @newpost.can_create? cuser %>
|
|
||||||
<%= link_to_function 'Fast Reply', "$('tr#reply').fadeIn('slow');" %> |
|
|
||||||
<%= link_to 'Reply', new_post_path(@newpost, :id => @topic) %> |
|
|
||||||
<% end %>
|
|
||||||
<% if @topic.can_update? cuser %>
|
|
||||||
<%= link_to 'Edit', edit_topic_path(@topic) %>
|
|
||||||
<% end %>
|
|
||||||
<% if @lock.new_record? and @lock.can_create? cuser %>
|
|
||||||
<%= form_for @lock, :html => {:style => "display:inline"} do |f| %>
|
|
||||||
<%= f.hidden_field :lockable_type %>
|
|
||||||
<%= f.hidden_field :lockable_id %>
|
|
||||||
| <%= link_to_function "Lock", "this.parentNode.submit()" %>
|
|
||||||
<% end %>
|
|
||||||
<% elsif @lock.can_destroy? cuser %>
|
|
||||||
| <%= link_to 'Unlock', @lock, :confirm => 'Are you sure?', :method => :delete %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="controls horizontal">
|
||||||
|
<%= f.submit 'Post Message' %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<%= will_paginate @posts %>
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<p>
|
<div class="right minitext">
|
||||||
<%= link_to "Forums", forums_url %> » <%= namelink @topic.forum %> » <%= namelink @topic %>
|
<% if @newpost.can_create? cuser %>
|
||||||
</p>
|
<%= link_to_function 'Fast Reply', "$('#reply').fadeIn('slow')", class: 'button' %>
|
||||||
|
<%= link_to 'Reply', new_post_path(@newpost, id: @topic), class: 'button' %>
|
||||||
|
<% end %>
|
||||||
|
<% if @topic.can_update? cuser %>
|
||||||
|
<%= link_to 'Edit', edit_topic_path(@topic), class: 'button' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if @lock.new_record? and @lock.can_create? cuser %>
|
||||||
|
<%= form_for @lock do |f| %>
|
||||||
|
<%= f.hidden_field :lockable_type %>
|
||||||
|
<%= f.hidden_field :lockable_id %>
|
||||||
|
<%= link_to_function "Lock", "this.parentNode.submit()", class: 'button' %>
|
||||||
|
<% end %>
|
||||||
|
<% elsif @lock.can_destroy? cuser %>
|
||||||
|
<%= link_to 'Unlock', @lock, class: 'button', confirm: 'Are you sure?', method: :delete %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render partial: 'breadcrumbs', locals: { topic: @topic } %>
|
||||||
|
</div>
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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!
|
||||||
|
|
|
@ -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'
|
||||||
|
|
66
lib/extra.rb
66
lib/extra.rb
|
@ -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
|
|
Loading…
Reference in a new issue