diff --git a/Gemfile b/Gemfile index dadae27..afac3de 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,7 @@ gem 'newrelic_rpm', '~> 3.7.2.195' gem 'will_paginate', '~> 3.0.5' gem 'dynamic_form', '~> 1.1.4' gem 'country_code_select', '~> 1.0.1' +gem 'active_link_to', '~> 1.0.2' gem 'rmagick', '~> 2.13.2', require: false gem 'sprockets', '~> 2.2.1' @@ -45,8 +46,10 @@ group :development do gem 'capistrano-bundler', '~> 1.1.2' gem 'capistrano-rails', '~> 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 'quiet_assets' + gem 'quiet_assets', '~> 1.0.2' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index af37a29..dc86ebb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,8 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) + active_link_to (1.0.2) + actionpack activemodel (3.2.17) activesupport (= 3.2.17) builder (~> 3.0.0) @@ -33,6 +35,11 @@ GEM rake (>= 0.8.7) arel (3.0.3) 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) bourbon (>= 3.1) sass (>= 3.2) @@ -86,6 +93,7 @@ GEM activesupport (>= 3.0) dalli (2.7.0) database_cleaner (1.2.0) + debug_inspector (0.0.2) debugger (1.6.6) columnize (>= 0.3.1) debugger-linecache (~> 1.2.0) @@ -265,8 +273,11 @@ PLATFORMS x86-mingw32 DEPENDENCIES + active_link_to (~> 1.0.2) annotate (~> 2.6.2) bbcoder (~> 1.0.1) + better_errors (~> 1.1.0) + binding_of_caller (~> 0.7.2) bitters (~> 0.9.3) bluecloth (~> 2.2.0) bourbon (~> 3.1.8) @@ -298,7 +309,7 @@ DEPENDENCIES oj (~> 2.5.5) poltergeist (~> 1.5.0) pry-debugger (~> 0.2.2) - quiet_assets + quiet_assets (~> 1.0.2) rails (~> 3.2.17) rmagick (~> 2.13.2) rspec-rails (~> 2.14.1) diff --git a/app/assets/images/layout/forum-category-highlight.png b/app/assets/images/layout/forum-category-highlight.png new file mode 100644 index 0000000..0d00675 Binary files /dev/null and b/app/assets/images/layout/forum-category-highlight.png differ diff --git a/app/assets/images/layout/forum-category.png b/app/assets/images/layout/forum-category.png new file mode 100644 index 0000000..61f4eaa Binary files /dev/null and b/app/assets/images/layout/forum-category.png differ diff --git a/app/assets/images/logo-icon.png b/app/assets/images/logo-icon.png new file mode 100644 index 0000000..dcd3211 Binary files /dev/null and b/app/assets/images/logo-icon.png differ diff --git a/app/assets/javascripts/local.js b/app/assets/javascripts/local.js index 2631fab..f1e4c06 100644 --- a/app/assets/javascripts/local.js +++ b/app/assets/javascripts/local.js @@ -191,10 +191,12 @@ function findUser(source) { return false; } -function QuoteText(id) { +function QuoteText(id, type) { + type = type || 'posts'; + $.ajax({ type: "GET", - url: "/posts/quote/" + id + ".js", + url: "/" + type + "/quote/" + id + ".js", dataType: "script" }); } diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/_variables.scss index 9291d45..a0529f1 100644 --- a/app/assets/stylesheets/_variables.scss +++ b/app/assets/stylesheets/_variables.scss @@ -42,6 +42,7 @@ $base-border-radius: em(3); Colours */ +$red: #de8650; $green: #1f7f5c; $blue: #5a9aa8; $purple: #6a5a8c; @@ -87,7 +88,7 @@ $navbar-text: white; $flash-text: white; $flash-notice: #5a9aa8; $flash-success: #1f7f5c; -$flash-warning: #de8650; +$flash-warning: $red; $flash-error: #e56c69; $input-primary: white; diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 4484d7e..d926447 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -24,6 +24,8 @@ @import "components/flashes"; @import "components/comments"; @import "components/gather"; +@import "components/breadcrumbs"; +@import "components/pagination"; /* Layout @@ -35,6 +37,7 @@ @import "layout/body"; @import "layout/sidebar"; @import "layout/footer"; +@import "layout/helpers"; /* Pages @@ -42,3 +45,4 @@ @import "pages/news"; @import "pages/contests"; +@import "pages/forums"; diff --git a/app/assets/stylesheets/components/_breadcrumbs.scss b/app/assets/stylesheets/components/_breadcrumbs.scss new file mode 100644 index 0000000..0a20a41 --- /dev/null +++ b/app/assets/stylesheets/components/_breadcrumbs.scss @@ -0,0 +1,16 @@ +/* + Breadcrumbs +*/ + +.breadcrumbs { + @include span-columns(12); + margin-bottom: em(20); + + a { + display: inline-block; + } + + .fa { + margin: 0 em(10); + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/components/_forms.scss b/app/assets/stylesheets/components/_forms.scss index c67c203..e2c9149 100644 --- a/app/assets/stylesheets/components/_forms.scss +++ b/app/assets/stylesheets/components/_forms.scss @@ -127,7 +127,8 @@ form.square { line-height: em(16); } - input { + input, + textarea { @include span-columns(9); } } diff --git a/app/assets/stylesheets/components/_pagination.scss b/app/assets/stylesheets/components/_pagination.scss new file mode 100644 index 0000000..db5869a --- /dev/null +++ b/app/assets/stylesheets/components/_pagination.scss @@ -0,0 +1,8 @@ +/* + Pagination +*/ + +.pagination { + @include span-columns(12); + margin: em(20) 0; +} \ No newline at end of file diff --git a/app/assets/stylesheets/layout/_body.scss b/app/assets/stylesheets/layout/_body.scss index 3acbb97..39a496a 100644 --- a/app/assets/stylesheets/layout/_body.scss +++ b/app/assets/stylesheets/layout/_body.scss @@ -1,10 +1,24 @@ +/* + Main Containers +*/ + +html, body { margin: 0; padding: 0; + width: 100%; + min-height: 100%; +} + +body { background: $dark-blue; @include background-image(linear-gradient($dark-blue, $medium-gray)); } +#container { + min-height: 100%; +} + %container-padded { padding: 0 em(20); } @@ -17,13 +31,16 @@ body { @extend %container-padded; } -#content, -#forums { +#content { @include span-columns(12); background: $light-blue; padding-top: em(20); } +#forums { + @include span-columns(12); +} + #main { @include span-columns(9); } @@ -32,14 +49,3 @@ body { @include span-columns(3); @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); -} \ No newline at end of file diff --git a/app/assets/stylesheets/layout/_helpers.scss b/app/assets/stylesheets/layout/_helpers.scss new file mode 100644 index 0000000..7d35bb1 --- /dev/null +++ b/app/assets/stylesheets/layout/_helpers.scss @@ -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; + } +} diff --git a/app/assets/stylesheets/layout/_navigation.scss b/app/assets/stylesheets/layout/_navigation.scss index d903343..65f94da 100644 --- a/app/assets/stylesheets/layout/_navigation.scss +++ b/app/assets/stylesheets/layout/_navigation.scss @@ -7,6 +7,7 @@ background-color: $background-primary; height: em(60); max-height: em(60); + nav { @include outer-container; } @@ -42,6 +43,7 @@ ul.navigation { padding: em(22); float: left; border-right: em(1) solid $navbar-border; + &:hover, &.active { background-color: $navbar-secondary; @@ -86,6 +88,10 @@ ul.navigation { li { border-bottom: em(1) solid lighten($navbar-secondary, 10%); + &:first-child { + border-top: em(1) solid lighten($navbar-secondary, 10%); + } + &:last-child { border-bottom: none; } diff --git a/app/assets/stylesheets/mixins/_buttons.scss b/app/assets/stylesheets/mixins/_buttons.scss index 7a4b715..ccd74f4 100644 --- a/app/assets/stylesheets/mixins/_buttons.scss +++ b/app/assets/stylesheets/mixins/_buttons.scss @@ -19,4 +19,16 @@ button, a.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; + } + } } diff --git a/app/assets/stylesheets/pages/_forums.scss b/app/assets/stylesheets/pages/_forums.scss new file mode 100644 index 0000000..5c646ff --- /dev/null +++ b/app/assets/stylesheets/pages/_forums.scss @@ -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; + } + } + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/pages/_news.scss b/app/assets/stylesheets/pages/_news.scss index 1b82c92..24a15cd 100644 --- a/app/assets/stylesheets/pages/_news.scss +++ b/app/assets/stylesheets/pages/_news.scss @@ -14,12 +14,26 @@ div.article { .author { @include span-columns(6); + + a { + font-weight: bold; + } } - .actions { + .comments { @include span-columns(6); @include omega; text-align: right; + + .fa { + margin-right: em(10); + } + } + + .actions { + @include span-columns(12); + @include omega; + margin-top: em(10); } &:first-child { @@ -50,4 +64,4 @@ div.article-links { padding-left: em(10); } } -} \ No newline at end of file +} diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 554c273..bb9d523 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,5 +1,5 @@ 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 def index @@ -47,6 +47,9 @@ class CommentsController < ApplicationController redirect_to_back end + def quote + end + private def get_comment diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index d4107f6..bf13ad8 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -46,13 +46,13 @@ class ForumsController < ApplicationController def up 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 end def down 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 end diff --git a/app/models/concerns/extra.rb b/app/models/concerns/extra.rb new file mode 100644 index 0000000..55093b9 --- /dev/null +++ b/app/models/concerns/extra.rb @@ -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/, "
").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 \ No newline at end of file diff --git a/app/models/forum.rb b/app/models/forum.rb index 0eb9c3a..1331234 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -13,6 +13,7 @@ class Forum < ActiveRecord::Base include Extra + BANS = 8 TRASH = 12 diff --git a/app/models/topic.rb b/app/models/topic.rb index 0c0fd68..fc405ca 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -30,7 +30,7 @@ class Topic < ActiveRecord::Base has_many :posts, :order => "id ASC", :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 :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)", @@ -39,7 +39,7 @@ class Topic < ActiveRecord::Base scope :latest_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 :first_post, :in => 1..10000, :on => :create diff --git a/app/models/user.rb b/app/models/user.rb index 570ac8d..7190a16 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -27,6 +27,7 @@ require File.join(Rails.root, 'vendor', 'plugins', 'acts_as_versioned', 'lib', ' class User < ActiveRecord::Base include Extra + VERIFICATION_TIME = 604800 attr_protected :id, :created_at, :updated_at, :lastvisit, :lastip, :password, :version diff --git a/app/views/application/_navigation.html.erb b/app/views/application/_navigation.html.erb index 1cae1f4..6ab9ab2 100644 --- a/app/views/application/_navigation.html.erb +++ b/app/views/application/_navigation.html.erb @@ -1,8 +1,8 @@ diff --git a/app/views/articles/_article.html.erb b/app/views/articles/_article.html.erb index 62c2346..05a24f0 100644 --- a/app/views/articles/_article.html.erb +++ b/app/views/articles/_article.html.erb @@ -13,14 +13,19 @@ <%= namelink(article.user) %> on <%= longtime article.created_at %> +
+ <%= link_to article do %> + <%= icon 'comments' %> Comments (<%= article.comments.count %>) + <% end %> +
+
<% if article.can_update? cuser %> - <%= link_to 'Edit', edit_article_path(article) %> | + <%= link_to 'Edit', edit_article_path(article), class: 'button tiny' %> <% end %> <% 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 %> - <%= link_to "History", article_versions_path(article) %> | - <%= link_to "Comments: #{article.comments.count}", article %> + <%= link_to "History", article_versions_path(article), class: 'button tiny' %>
diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index b500805..7959fc2 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -11,7 +11,7 @@
<% 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 %> <%= link_to 'E', edit_comment_path(comment) %> <% end %> diff --git a/app/views/comments/_new.html.erb b/app/views/comments/_new.html.erb index 8afa1d7..4faef68 100644 --- a/app/views/comments/_new.html.erb +++ b/app/views/comments/_new.html.erb @@ -1,4 +1,4 @@ -
+
New comment
<% if cuser %> @@ -11,7 +11,7 @@ <%= f.hidden_field :commentable_id %> <%= f.hidden_field :commentable_type %>
- <%= f.text_area :text, rows: 5, cols: 40, id: "textArea" %> + <%= f.text_area :text, rows: 5 %>
<%= f.submit 'Post Comment' %> diff --git a/app/views/comments/quote.js.erb b/app/views/comments/quote.js.erb new file mode 100644 index 0000000..5a4a95d --- /dev/null +++ b/app/views/comments/quote.js.erb @@ -0,0 +1 @@ +$("#reply textarea").append("[quote=<%= @comment.user %>]<%= escape_javascript(@comment.text) %>[/quote]\n"); diff --git a/app/views/forums/_controls.html.erb b/app/views/forums/_controls.html.erb new file mode 100644 index 0000000..2ef86a7 --- /dev/null +++ b/app/views/forums/_controls.html.erb @@ -0,0 +1,11 @@ +
+ <% 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 %> +
\ No newline at end of file diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 25d7d5a..5965a42 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,46 +1,44 @@ -
- -
+
<% @categories.each do |cat| %> <% forums = cuser ? cat.forums.available_to(cuser, Forumer::ACCESS_READ).ordered : cat.forums.public.ordered %> <% next if forums.length == 0 %> + +

<%=h cat.name %>

- +
- - - - - - - + + + + + <% forums.each do |forum| %> - + - - - + + + @@ -48,28 +46,21 @@
- <%= h cat.to_s %> -
ForumsTopicsPostsLast PostForumsTopicsPostsLast Post
"> "> -
-

- <%= namelink forum %> -

- <%= forum.description %> -
-
- <% if forum.can_update? cuser %> - <%= link_to "Up", :action => "up", :id => forum %>
- <%= link_to "Down", :action => "down", :id => forum %> - <% end %> -
-
+
<%= namelink(forum) %>
+ <%= forum.description %>
<%= forum.topics.count %><%= forum.posts.count %> + + <% if forum.can_update? cuser %> + <%= link_to action: "up", id: forum do %> + <% icon 'arrow-up' %> + <% end %> + <%= link_to action: "down", id: forum do %> + <% icon 'arrow-down' %> + <% end %> + <% end %> + <%= forum.topics.count %><%= forum.posts.count %> <% if forum.posts.last %> - <%= link_to raw("#{h forum.posts.last.user}
#{shortdate forum.posts.last.created_at}"), lastpost(forum.posts.last.topic) %> + <%= link_to lastpost(forum.posts.last.topic) do %> + <%=h forum.posts.last.user %>
+ <%= shortdate(forum.posts.last.created_at) %> + <% end %> <% end %>
<% end %> +
-
- - - - - - - - -
- Statistics -
- We have total of <%= Post.count %> posts, - <%= Topic.count %> topics, and <%= User.count %> users. - Our newest member is <%= namelink User.last %> and most active member is <%= namelink User.posts_stats.first %>. -
-
+
+

Statistics

+

+ We have total of <%= Post.count %> posts, + <%= Topic.count %> topics, and <%= User.count %> users. +

+

+ Our newest member is <%= namelink User.last %> and most active member is <%= namelink User.posts_stats.first %>. +

<% if Forum.new.can_create? cuser %>

- <%= link_to 'New forum', new_forum_path %> + <%= link_to 'New forum', new_forum_path, class: "button" %>

<% end %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index fef8300..86f5a22 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,75 +1,51 @@ -

- <%= link_to "Forums", :action => "index" %> » <%= namelink @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 %> -

- - -
-
- - - - - - - - - - - - <% @forum.topics.basic.ordered.each do |topic| %> - - - - - - - - <% end %> -
- <%= h @forum.title %> -
TopicAuthorRepliesViewsLast Post
-

- <% if topic.state == Topic::STATE_STICKY %> - Sticky: - <% elsif topic.lock %> - Locked: - <% 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 %> -

-
<%= namelink topic.user %><%= h topic.posts.count-1 %><%= h topic.view_count %> - <%= link_to raw("#{h topic.posts.last.user}
#{shortdate topic.posts.last.created_at}"), lastpost(topic) %> -
-
- -

- <% 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 %> -

+ + +<%= render partial: 'controls', locals: { forum: @forum } %> + +

<%=h @forum.title %>

+ + + + + + + + + + <% @forum.topics.basic.ordered.each do |topic| %> + + + + + + + + <% end %> +
TopicAuthorRepliesViewsLast Post
+
+ <% if topic.state == Topic::STATE_STICKY %> + Sticky: + <% elsif topic.lock %> + Locked: + <% end %> + + <%= link_to (h topic), topic, class: ((cuser and !topic.read_by? cuser) ? "unread" : "read") %> +
+ + <% 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 %> +
<%= namelink(topic.user) %><%=h topic.posts.count-1 %><%=h topic.view_count %> + <%= link_to lastpost(topic) do %> + <%=h topic.posts.last.user %>
+ <%= shortdate(topic.posts.last.created_at) %> + <% end %> +
+ +<%= render partial: 'controls', locals: { forum: @forum } %> diff --git a/app/views/posts/_post.html.erb b/app/views/posts/_post.html.erb index 33784f5..3e388a4 100644 --- a/app/views/posts/_post.html.erb +++ b/app/views/posts/_post.html.erb @@ -1,69 +1,58 @@ -<% if n > 0 or n == -1 %> - - - - -<% end %> +
+
+
+ <%= link_to post.user, post.user, class: ("admin" if post.user.admin?) %> +
- - -

- <%= link_to post.user, post.user, :class => (post.user.admin? ? "red" : "") %> -

- - <%= image_tag post.user.profile.avatar.url, :class => "centered" %> +
+ <%= image_tag post.user.profile.avatar.url %> +
<% if post.user.team %> -

- <%= namelink post.user.team %> -

+ <%= namelink post.user.team %> <% end %> + <%= cascade post.user, [["Posts", "posts.count"], "from", "joined"] %> - +
- -
- - <%= longtime post.created_at %> - +
+
+ +
+ <%= link_to "##{post.number(@posts, n)}", "#post_#{post.id}" %> +
-
- <%= post.number @posts, n %> +
+ <%= post.text_parsed.html_safe %>
- -
- - - - - - <%= post.text_parsed.html_safe %> - - - - - - <%= link_to "Send PM", :controller => "messages", :action => "new", :id => "User", :id2 => post.user %> - - - -
- <%= raw post.user.profile.signature_parsed if post.user.profile.signature_parsed %> + +
+ <%= post.user.profile.signature_parsed.html_safe if post.user.profile.signature_parsed %>
+
-
- <% if post.topic.posts.build.can_create? cuser %> - <%= link_to_function 'QuoteReply', "QuoteText(#{post.id}); $('tr#reply').fadeIn('slow');" %> - <% end %> - <% if post.can_update? cuser %> - <%= link_to 'Edit', edit_post_path(post) %> - <% end %> - <% if post.can_destroy? cuser %> - <%= link_to 'Delete', post, :confirm => 'Are you sure?', :method => :delete %> - <% end %> +
+
+ <%= link_to "Send PM", { controller: "messages", action: "new", id: "User", id2: post.user }, class: 'button tiny' %>
- -
- - + +
+
+ <% if post.topic.posts.build.can_create? cuser %> + <%= link_to_function 'Quote Reply', "QuoteText(#{post.id}); $('#reply').fadeIn('slow')", class: 'button tiny' %> + <% end %> + <% if post.can_update? cuser %> + <%= link_to 'Edit', edit_post_path(post), class: 'button tiny' %> + <% end %> + <% if post.can_destroy? cuser %> + <%= link_to 'Delete', post, confirm: 'Are you sure?', method: :delete, class: 'button tiny' %> + <% end %> +
+
+
+
diff --git a/app/views/posts/create.js.erb b/app/views/posts/create.js.erb index 42a9a9d..ddcf6d0 100644 --- a/app/views/posts/create.js.erb +++ b/app/views/posts/create.js.erb @@ -1,2 +1,2 @@ -$("tr#reply").hide(); -$("tbody#posts").append("<%= escape_javascript(render(:partial => "post", :locals => {:post => @post, :n => -1})) %>"); \ No newline at end of file +$("#reply").find("textarea").val("").end().hide(); +$("#posts").append("<%= escape_javascript(render(partial: 'post', locals: { post: @post, n: -1 })) %>"); diff --git a/app/views/posts/quote.js.erb b/app/views/posts/quote.js.erb index c19bde5..503e912 100644 --- a/app/views/posts/quote.js.erb +++ b/app/views/posts/quote.js.erb @@ -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"); diff --git a/app/views/topics/_breadcrumbs.html.erb b/app/views/topics/_breadcrumbs.html.erb new file mode 100644 index 0000000..cb89e4e --- /dev/null +++ b/app/views/topics/_breadcrumbs.html.erb @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 4f8bb35..a65041b 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -1,96 +1,70 @@ -

- <%= link_to "Forums", forums_url %> » <%= namelink @topic.forum %> » <%= namelink @topic %> -

+
+ <%= render partial: 'breadcrumbs', locals: { topic: @topic } %> - - - - - - +
+ <% if @newpost.can_create? cuser %> + <%= 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 %> +
- - <% n = 0; @posts.each do |post| %> - <%= render :partial => "posts/post", :locals => {:post => post, :n => n} %> - <% n = n + 1 end %> - <% if @newpost.errors.count > 0 %> - - - +
+ <% @posts.each_with_index do |post, n| %> + <%= render partial: "posts/post", locals: { post: post, n: n } %> + <% end %> + + <% if @newpost.errors.count > 0 %> + <% @newpost.error_messages.each do |m| %> + <%= h m %>
<% end %> -
+ <% end %> + - - - - - - - - - -
-
- <%= namelink @topic %> - <% if @posts.length > Topic::POSTS_PAGE %> - [<%= will_paginate @posts %>] - <% end %> -
+

<%= namelink @topic %>

-
- <% if @newpost.can_create? cuser %> - <%= link_to 'Reply', new_post_path(@newpost, :id => @topic) %> | - <% end %> - <% if @topic.can_update? cuser %> - <%= link_to 'Edit', edit_topic_path(@topic) %> - <% end %> -
+ <% if @posts.count > Topic::POSTS_PAGE %> + <%= will_paginate @posts %> + <% end %> -
-
- <% @newpost.error_messages.each do |m| %> - <%= h m %>
- <% end %> -
-
- <%= form_for(@newpost, :remote => true) do |f| %> - <%= f.error_messages %> - <%= f.hidden_field :topic_id %> -

- <%= f.text_area :text, :rows => 13, :cols => 70, :id => "textArea" %> -

-

- <%= f.submit 'Post Message' %> -

- <% end %> -
-
-
- <%= will_paginate @posts %> -
- -
- <% 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 %> +
+
New Reply
+ + <%= form_for(@newpost, remote: true, html: { class: 'square' }) do |f| %> + <%= f.error_messages %> + <%= f.hidden_field :topic_id %> +
+ <%= f.label "Enter your post text:" %> + <%= f.text_area :text, rows: 10 %>
+
+ <%= f.submit 'Post Message' %> +
+ <% end %> +
-
-
+ <%= will_paginate @posts %> -

- <%= link_to "Forums", forums_url %> » <%= namelink @topic.forum %> » <%= namelink @topic %> -

+
+ <% if @newpost.can_create? cuser %> + <%= 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 %> +
+ + <%= render partial: 'breadcrumbs', locals: { topic: @topic } %> +
diff --git a/config/application.rb b/config/application.rb index b1f033f..8e08714 100644 --- a/config/application.rb +++ b/config/application.rb @@ -10,7 +10,7 @@ module Ensl # -- all .rb files in that directory are automatically loaded. # 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). # :all can be used as a placeholder for all plugins nowt explicitly named. diff --git a/config/deploy.rb b/config/deploy.rb index 7bc1a43..893cff3 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -5,7 +5,7 @@ set :deploy_via, :remote_cache set :pty, true 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 :rbenv_type, :user diff --git a/config/environment.rb b/config/environment.rb index cf06d20..0c9b38c 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,7 +1,6 @@ require File.expand_path('../application', __FILE__) require 'verification' require 'exceptions' -require 'extra' ActiveSupport::Deprecation.silenced = true Ensl::Application.initialize! diff --git a/config/initializers/bbcoder.rb b/config/initializers/bbcoder.rb index 670f499..fd20388 100644 --- a/config/initializers/bbcoder.rb +++ b/config/initializers/bbcoder.rb @@ -24,4 +24,4 @@ BBCoder.configure do %(#{content}) end end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index e46dd5a..b7e843d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,6 +13,9 @@ Ensl::Application.routes.draw do resources :categories resources :options resources :polls + + match 'comments/quote' + resources :comments resources :shoutmsgs resources :teamers @@ -23,6 +26,10 @@ Ensl::Application.routes.draw do resources :groupers resources :forumers resources :topics + + match 'forums/up' + match 'forums/down' + resources :forums resources :users resources :locks @@ -46,6 +53,9 @@ Ensl::Application.routes.draw do resources :bans resources :tweets resources :issues + + match 'posts/quote' + resources :posts resources :brackets @@ -74,9 +84,6 @@ Ensl::Application.routes.draw do match 'directories', to: "directories#show", id: 1 - match 'forums/up' - match 'forums/down' - match 'gathers/refresh' match 'gathers/latest/:game', to: "gathers#latest", 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/login' - match 'posts/quote' - match 'users/agenda' match 'users/login' match 'users/logout' diff --git a/lib/extra.rb b/lib/extra.rb deleted file mode 100644 index 7d10abf..0000000 --- a/lib/extra.rb +++ /dev/null @@ -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/, "
").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 \ No newline at end of file