diff --git a/Gemfile b/Gemfile index 4714ee3..4216fe2 100644 --- a/Gemfile +++ b/Gemfile @@ -15,6 +15,7 @@ gem 'activerecord-session_store' gem 'highlight_js-rails', github: 'RedstonerServer/highlight_js-rails' gem 'kaminari', github: 'jomo/kaminari', branch: 'patch-2' # pagination gem 'jquery-textcomplete-rails', github: 'RedstonerServer/jquery-textcomplete-rails' # @mentions +gem 'actionpack-action_caching', github: 'antulik/actionpack-action_caching', ref: '8c6e52c69315d67437f480da5dce4b7c8737fb32' # Gems used only for assets and not required # in production environments by default. @@ -43,4 +44,4 @@ end group :production do # Use unicorn as the app server gem 'unicorn' -end \ No newline at end of file +end diff --git a/Gemfile.lock b/Gemfile.lock index 1e638b9..c04ca64 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -14,6 +14,14 @@ GIT railties (>= 3.2.0) sass-rails (>= 3.2.0) +GIT + remote: git://github.com/antulik/actionpack-action_caching.git + revision: 8c6e52c69315d67437f480da5dce4b7c8737fb32 + ref: 8c6e52c69315d67437f480da5dce4b7c8737fb32 + specs: + actionpack-action_caching (1.2.0) + actionpack (>= 4.0.0, < 6) + GIT remote: git://github.com/jomo/kaminari.git revision: e49066e94d77a6abb03a0819f3c4b0cc6923cb70 @@ -223,6 +231,7 @@ PLATFORMS ruby DEPENDENCIES + actionpack-action_caching! activerecord-session_store bcrypt better_errors diff --git a/app/assets/javascripts/editor.js b/app/assets/javascripts/editor.js index 4b35aea..4f4de5d 100644 --- a/app/assets/javascripts/editor.js +++ b/app/assets/javascripts/editor.js @@ -88,5 +88,45 @@ $(function() { }], { debounce: 300 }); + $('.md_editor .field_container_user .editor_field').textcomplete([{ + // match up to 2 words (everything except some special characters) + // each word can have up to 16 characters (up to 32 total) + // words must be separated by a single space + match: /(^|\s)([^!"§$%&\/()=?.,;+*@\s]{1,16})$/, + search: function (text, callback, match) { + console.log("Searching " + text); + text = text.toLowerCase(); + $.ajax("/users/suggestions", { + type: "post", + data: {name: text}, + dataType: "json", + headers: { + "X-CSRF-Token": $('meta[name="csrf-token"]').attr("content") + }, + success: function(data) { + callback(data); + }, + error: function(xhr, status, err) { + console.error(err); + callback([]); + } + }); + }, + template: function(user) { + var name = user[0]; + var ign = user[1]; + if (name != ign) { + return name + " (" + ign + ")"; + } else { + return ign; + } + }, + cache: true, + replace: function (word) { + return "$1" + word[1] + " "; + } + }], { + debounce: 300 + }); -}); \ No newline at end of file +}); diff --git a/app/assets/stylesheets/dark.css.scss b/app/assets/stylesheets/dark.css.scss new file mode 100644 index 0000000..90c7fc0 --- /dev/null +++ b/app/assets/stylesheets/dark.css.scss @@ -0,0 +1,105 @@ +body { + background-color:rgb(50, 50, 50); + text-shadow:none !important; + color:rgb(190, 190, 190) !important; +} +::selection { + background-color:rgb(100, 150, 255); +} +a { + color:rgb(203, 75, 22); + border-color:black !important; +} +a:hover { + color:rgb(215, 100, 40); +} +#main-content { + border-color:black !important; + padding:30px 100px; + box-shadow:none; +} +#main-content-scroll { + padding: 131px 100px; + border: 1px solid #000; + box-shadow: 0 0 5px #000; +} +hr { + background-color:black !important; + border-color:black !important; +} +code { + background-color:rgb(30, 30, 30) !important; + border-color:black !important; + color:white !important; +} +#head_top { + width:100%; + z-index:100; +} +#head_scroll { + @extend #head_top; + position: fixed; + width: 100%; + z-index: 1; +} +div#userbar { + background-color:rgb(90, 90, 90) !important; + border-color:black !important; + color:white !important; + text-shadow:none !important; +} +#head a { + text-shadow:none !important; + color:white !important; +} +#head a:hover { + color:rgb(190, 190, 190) !important; +} +.header { + background-color:rgb(0, 0, 0); + border:none !important; +} +input[type="email"], input[type="text"], input[type="password"] { + background-color:rgb(110, 110, 110) !important; + color:white !important; +} +::placeholder { + color:lightgray; +} +.item { + background-color:rgb(40, 40, 40) !important; + border-color:black !important; +} +.item-group { + border-color:black !important; +} +div.header { + background-color:rgb(20, 20, 20) !important; +} +.avatar { + border-color:black !important; +} +.items { + border-color:black !important; +} +.markdown-help { + background-color:rgb(90, 90, 90); + color:white; + border-color:black; +} +textarea { + background-color:rgb(100, 100, 100); + color:white; +} +.headline { + border-color:black !important; +} +.role { + opacity:0.7 !important; +} +.label { + opacity:0.7 !important; +} +.notice { + color:white; +} diff --git a/app/assets/stylesheets/mobi.css.scss b/app/assets/stylesheets/mobi.css.scss index cc437cb..c1b44fd 100644 --- a/app/assets/stylesheets/mobi.css.scss +++ b/app/assets/stylesheets/mobi.css.scss @@ -4,12 +4,12 @@ th, td { // force tables into line-mode - // it's a bit ugly, but probably the best + // it''s a bit ugly, but probably the best // solution for small screens display: block; } - #head { + #head_top { #menu { #logo { display: none; @@ -17,10 +17,19 @@ } } + #head_scroll { + @extend #head_top; + position: fixed; +} + #main-content { padding: 30px 5px; } + #main-content-scroll { + padding: 181px 5px; + } + .front-page { h1 { font-size: 2em !important; @@ -66,4 +75,4 @@ margin: 50px 20px 0; } -} \ No newline at end of file +} diff --git a/app/assets/stylesheets/style.css.scss b/app/assets/stylesheets/style.css.scss index 6de5aa2..f8d1d8e 100644 --- a/app/assets/stylesheets/style.css.scss +++ b/app/assets/stylesheets/style.css.scss @@ -80,7 +80,7 @@ a { } } -#head { +#head_top { background: #3f3f3f; #menu { @@ -181,6 +181,13 @@ a { } } +#head_scroll { + @extend #head_top; + position: fixed; + width: 100%; + z-index: 1; +} + .front-page { margin: auto; text-align: center; @@ -260,6 +267,11 @@ span.no-about { } } +#main-content-scroll { + @extend #main-content; + padding: 131px 100px; +} + #user-info { .user-avatar { margin-bottom: 30px; @@ -437,18 +449,14 @@ blockquote p { color: #ddd !important; } } - - .donor { - color: #fff; - background: #f60 !important; - margin-left: 2px !important; - } - .ign { display: block; color: #000; font-style: italic; } + .badge { + margin-left: 2px !important; + } } #online-users { @@ -458,6 +466,7 @@ blockquote p { } .md_editor { + .field_container { position: relative; @@ -465,7 +474,7 @@ blockquote p { position: absolute; top: 1em; left: 1em; - z-index: 10; + z-index: 0; } .editor_field { @@ -480,6 +489,10 @@ blockquote p { padding: 4em 1em 1em; } } + .field_container_user { + .editor_field { + } + } } ul.dropdown-menu { @@ -675,6 +688,13 @@ tr.spacer { color: #ddd; } + &.variable-size { + background: #4096ee; + @media only screen and (max-width: 500px) { + font-size: 9px; + } + } + &.blue { background: #4096ee; @@ -1026,4 +1046,20 @@ nav.pagination { padding: 0.1em 0.2em; border-radius: 0.2em; text-shadow: none; -} \ No newline at end of file +} + +.searchfield { + height:40px; + display: inline-block; + &.field { + width: 300px; + } + &.btn { + margin: 4px 1px 0 0; + cursor: default; + color: #fff; + font-size: 12px; + background: #4096ee; + width: 40px; + } +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a0e166e..d489611 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -75,4 +75,4 @@ class ApplicationController < ActionController::Base !!(current_user && current_user.confirmed?) end -end \ No newline at end of file +end diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index 79c9e5d..7a9851d 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -75,4 +75,4 @@ class BlogpostsController < ApplicationController end end -end \ No newline at end of file +end diff --git a/app/controllers/forumgroups_controller.rb b/app/controllers/forumgroups_controller.rb index a7b31ab..fe359af 100644 --- a/app/controllers/forumgroups_controller.rb +++ b/app/controllers/forumgroups_controller.rb @@ -77,4 +77,4 @@ class ForumgroupsController < ApplicationController params.require(:forumgroup).permit(a) end -end \ No newline at end of file +end diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index ecf570e..761a86b 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -1,4 +1,5 @@ class ForumsController < ApplicationController + before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index @@ -77,7 +78,6 @@ class ForumsController < ApplicationController redirect_to forums_path end - private def check_permission @@ -89,7 +89,7 @@ class ForumsController < ApplicationController end def forum_params(add = []) - a = [:name, :position, :role_read_id, :role_write_id] + add + a = [:name, :position, :role_read_id, :role_write_id, :necro_length] + add params.require(:forum).permit(a) end -end \ No newline at end of file +end diff --git a/app/controllers/forumthreads_controller.rb b/app/controllers/forumthreads_controller.rb index b9b5714..81d420a 100644 --- a/app/controllers/forumthreads_controller.rb +++ b/app/controllers/forumthreads_controller.rb @@ -3,11 +3,19 @@ class ForumthreadsController < ApplicationController before_filter :check_permission, only: [:show, :edit, :update, :destroy] def index - redirect_to forum_path(@thread.forum.forumgroup, f) - end + params[:forum] = nil if params[:forum] && !Forum.find_by(id: params[:forum]) + params.delete_if{|k,v| v.blank?} + + @threads = Forumthread.filter(current_user, params[:title].try(:slice, 0..255), params[:content].try(:slice, 0..255), params[:reply].try(:slice, 0..255), params[:label], User.find_by(ign: params[:author].to_s.strip) || params[:author], params[:query].try(:slice, 0..255), Forum.find_by(id: params[:forum])) + .page(params[:page]).per(30) + end def show - @replies = @thread.replies.page(params[:page]) + if params[:reverse] == "true" + @replies = @thread.replies.reverse_order.page(params[:page]) + else + @replies = @thread.replies.page(params[:page]) + end end def edit @@ -76,6 +84,9 @@ class ForumthreadsController < ApplicationController redirect_to @thread.forum end + def search + end + private def check_permission @@ -92,4 +103,4 @@ class ForumthreadsController < ApplicationController a += add params.require(:forumthread).permit(a) end -end \ No newline at end of file +end diff --git a/app/controllers/statics_controller.rb b/app/controllers/statics_controller.rb index f2891f3..4b0c911 100644 --- a/app/controllers/statics_controller.rb +++ b/app/controllers/statics_controller.rb @@ -1,5 +1,7 @@ class StaticsController < ApplicationController + caches_action :online, expires_in: 10.seconds, layout: false + def index if current_user redirect_to blogposts_path @@ -14,4 +16,9 @@ class StaticsController < ApplicationController def donate end + def online + json = JSON.parse(File.read("/etc/minecraft/redstoner/plugins/JavaUtils/players.json")) + @players = json["players"].collect!{ |p| User.find_by(uuid: p["UUID"].tr("-", "")) or User.new(name: p["name"], ign: p["name"], uuid: p["UUID"].tr("-", ""), role: Role.get("normal"), badge: Badge.get("none"), confirmed: true) }.sort_by!(&:role).reverse! + @count = json["amount"] + end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5dc0e80..dd12a98 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,24 +7,10 @@ class UsersController < ApplicationController before_filter :set_user, except: [:index, :new, :create, :lost_password, :reset_password, :suggestions] def index - if params[:role] - if params[:role].downcase == "staff" - @users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) - elsif params[:role].downcase == "donor" - @users = User.joins(:role).where(donor: true) - else - if role = Role.get(params[:role]) - @users = User.joins(:role).where(role: role) - else - flash[:alert] = "role '#{params[:role]}' does not exist!" - redirect_to users_path - return - end - end - else - @users = User.joins(:role).where.not(id: User.first.id) #Remove first user - end - @users = @users.order("roles.value desc", "confirmed desc", :name) + role = Role.find_by(name: params[:role]) + badge = Badge.find_by(name: params[:badge]) + + @users = User.search(params[:search], role, badge, params[:staff]) @count = @users.size @users = @users.page(params[:page]).per(100) end @@ -151,9 +137,9 @@ class UsersController < ApplicationController def update if (mod? && current_user.role >= @user.role ) || (@user.is?(current_user) && confirmed?) if mod? - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :confirmed, :donor]) + userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :role, :badge, :confirmed, :header_scroll, :utc_time, :dark]) else - userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about]) + userdata = user_params([:name, :skype, :skype_public, :youtube, :twitter, :about, :header_scroll, :utc_time, :dark]) end if userdata[:role] role = Role.get(userdata[:role]) @@ -164,6 +150,9 @@ class UsersController < ApplicationController userdata.delete(:role) end end + if userdata[:badge] + userdata[:badge] = Badge.get(userdata[:badge]) + end if @user.youtube != userdata[:youtube] youtube = get_youtube(userdata[:youtube]) userdata[:youtube] = youtube[:channel] @@ -232,6 +221,13 @@ class UsersController < ApplicationController end end + def edit_website_settings + unless @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? + flash[:alert] = "You are not allowed to edit this user's website settings!" + redirect_to @user + end + end + def update_login if @user.is?(current_user) || admin? && current_user.role > @user.role || superadmin? authenticated = !@user.is?(current_user) || @user.authenticate(params[:current_password]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1419391..a1bf22c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -11,10 +11,12 @@ module ApplicationHelper end def ago(tm) - if tm + if tm && current_user.try(:utc_time) != true content_tag :time, title: tm.strftime("%e %b %Y, %H:%M %Z"), datetime: tm.to_datetime.rfc3339 do tm.strftime("%e %b %Y, %H:%M") end + else + tm end end @@ -90,4 +92,4 @@ module ApplicationHelper https://www.youtube-nocookie.com/embed/\\1?theme=light&vq=hd720&hd=1&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1&html5=1&start=\\3'> ") end -end \ No newline at end of file +end diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index dbacf81..5e5649c 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -24,4 +24,4 @@ module MailerHelper end end end -end \ No newline at end of file +end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2ce1765..7ad99d8 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -52,4 +52,4 @@ module UsersHelper end end -end \ No newline at end of file +end diff --git a/app/models/badge.rb b/app/models/badge.rb new file mode 100644 index 0000000..ee3de34 --- /dev/null +++ b/app/models/badge.rb @@ -0,0 +1,18 @@ +class Badge < ActiveRecord::Base + include Comparable + has_many :users + + def self.get (input) + if input.is_a?(String) || input.is_a?(Symbol) + Badge.find_by(name: input) + elsif input.is_a?(Fixnum) + Badge.find_by(id: input) + elsif input.is_a?(Badge) + return input + end + end + + def to_s + self.name + end +end diff --git a/app/models/comment.rb b/app/models/comment.rb index 35a9a60..951d684 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -61,4 +61,4 @@ class Comment < ActiveRecord::Base background_mailer(mails) end -end \ No newline at end of file +end diff --git a/app/models/forum.rb b/app/models/forum.rb index 39e8f2a..a239dbc 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -32,4 +32,4 @@ class Forum < ActiveRecord::Base def to_param [id, to_s.parameterize].join("-") end -end \ No newline at end of file +end diff --git a/app/models/forumthread.rb b/app/models/forumthread.rb index 905e4d3..f8efe97 100644 --- a/app/models/forumthread.rb +++ b/app/models/forumthread.rb @@ -65,4 +65,49 @@ class Forumthread < ActiveRecord::Base def to_param [id, to_s.parameterize].join("-") end + + def self.filter (user, title, content, reply, label, author, query, forum) + order_phrase = query || [title, content, reply].select(&:present?).join(" ") + user_id = user.try(:id).to_i + role_value = user.try(:role).to_i + can_read = "COALESCE(forum_role_read.value, 0) <= ? AND COALESCE(forumgroup_role_read.value, 0) <= ?" + # A user can view sticky threads in write-only forums without read permissions. + sticky_can_write = "sticky = true AND (COALESCE(forum_role_write.value, 0) <= ? AND COALESCE(forumgroup_role_write.value, 0) <= ?)" + match = ["MATCH (title, forumthreads.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (threadreplies.content) AGAINST (#{Forumthread.sanitize(order_phrase)})", "MATCH (title, forumthreads.content) AGAINST (?) OR MATCH (threadreplies.content) AGAINST (?)", "MATCH (title) AGAINST (?)", "MATCH (forumthreads.content) AGAINST (?)", "MATCH (threadreplies.content) AGAINST (?)"] + + threads = forum.try(:forumthreads) || Forumthread + + threads = threads.select("forumthreads.*", "#{match[0]} AS relevance", "#{match[1]} AS reply_rel") + + threads = threads.joins(forum: :forumgroup) + .joins("LEFT JOIN threadreplies ON forumthreads.id = threadreplies.forumthread_id") + .joins("LEFT JOIN roles as forum_role_read ON forums.role_read_id = forum_role_read.id") + .joins("LEFT JOIN roles as forum_role_write ON forums.role_write_id = forum_role_write.id") + .joins("LEFT JOIN roles as forumgroup_role_read ON forumgroups.role_read_id = forumgroup_role_read.id") + .joins("LEFT JOIN roles as forumgroup_role_write ON forumgroups.role_write_id = forumgroup_role_write.id") + + threads = threads.where("forumthreads.user_author_id = ? OR (#{can_read}) OR (#{sticky_can_write})", user_id, role_value, role_value, role_value, role_value) + if query + threads = threads.where("#{match[2]}", query[0..99], query[0..99]) + elsif [title, content, reply].any? + threads = threads.where("#{match[3]}", title[0..99]) if title + threads = threads.where("#{match[4]}", content[0..99]) if content + threads = threads.where("#{match[5]}", reply[0..99]) if reply + end + if label.try(:downcase) == "no label" + threads = threads.where(label: nil) + elsif label && l = Label.find_by(name: label) + threads = threads.where(label: l) + end + threads = threads.where(user_author: author) if author + + threads = threads.group("forumthreads.id") + + if order_phrase.present? + threads = threads.order("GREATEST(relevance, reply_rel) DESC") + else + threads = threads.order("sticky desc", "threadreplies.created_at DESC", "forumthreads.created_at DESC") + end + threads + end end diff --git a/app/models/info.rb b/app/models/info.rb index b900ad0..cbfa1d3 100644 --- a/app/models/info.rb +++ b/app/models/info.rb @@ -11,4 +11,4 @@ class Info < ActiveRecord::Base [id, to_s.parameterize].join("-") end -end \ No newline at end of file +end diff --git a/app/models/label.rb b/app/models/label.rb index ee2fb56..d7cdc30 100644 --- a/app/models/label.rb +++ b/app/models/label.rb @@ -23,4 +23,4 @@ class Label < ActiveRecord::Base end end end -end \ No newline at end of file +end diff --git a/app/models/register_token.rb b/app/models/register_token.rb index 36c0cd1..5b956ff 100644 --- a/app/models/register_token.rb +++ b/app/models/register_token.rb @@ -1,2 +1,2 @@ class RegisterToken < ActiveRecord::Base -end \ No newline at end of file +end diff --git a/app/models/role.rb b/app/models/role.rb index 708fb40..5e5efa5 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -14,14 +14,14 @@ class Role < ActiveRecord::Base end def is? (name) - !!(Role.find_by_name(name) == self) + !!(Role.find_by(name: name) == self) end def self.get (input) if input.is_a?(String) || input.is_a?(Symbol) - Role.find_by_name(input) + Role.find_by(name: input) elsif input.is_a?(Fixnum) - Role.find_by_id(input) + Role.find_by(id: input) elsif input.is_a?(Role) return input end @@ -31,7 +31,7 @@ class Role < ActiveRecord::Base if role.is_a?(Role) self.value - role.value elsif role.is_a?(Symbol) - self <=> Role.find_by_name(role) + self <=> Role.find_by(name: role) else self.to_i <=> role end @@ -53,4 +53,4 @@ class Role < ActiveRecord::Base Role.order(:value).select {|r| r >= from}.select {|r| r <= to} end -end \ No newline at end of file +end diff --git a/app/models/threadreply.rb b/app/models/threadreply.rb index 47b0d97..f285073 100644 --- a/app/models/threadreply.rb +++ b/app/models/threadreply.rb @@ -64,4 +64,4 @@ class Threadreply < ActiveRecord::Base end background_mailer(mails) end -end \ No newline at end of file +end diff --git a/app/models/user.rb b/app/models/user.rb index c422e28..d755646 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,10 +5,11 @@ class User < ActiveRecord::Base strip_attributes belongs_to :role + belongs_to :badge has_secure_password - before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role + before_validation :strip_whitespaces, :set_uuid, :set_name, :set_email_token, :set_role, :set_badge validates_presence_of :password, :password_confirmation, :email_token, on: :create validates_presence_of :name, :email, :ign @@ -29,10 +30,6 @@ class User < ActiveRecord::Base self == user end - def donor? - !!self.donor - end - def confirmed? !!self.confirmed end @@ -150,6 +147,10 @@ class User < ActiveRecord::Base self.role ||= Role.get(:normal) end + def set_badge + self.badge ||= Badge.get(:none) + end + def set_uuid if !self.uuid.present? # idk @@ -173,4 +174,23 @@ class User < ActiveRecord::Base def set_email_token self.email_token ||= SecureRandom.hex(16) end -end \ No newline at end of file + + def self.search (search, role, badge, staff) + if role + if staff + users = User.joins(:role).where("roles.value >= ?", Role.get(:mod).to_i) + else + users = User.joins(:role).where(role: role) + end + end + if badge + users = User.joins(:badge).where(badge: badge) + else + users = User.joins(:role).all.where.not(id: User.first.id) + end + search_san = User.send(:sanitize_sql_like, search.to_s) + users = users.where("users.name like ? OR ign like ?", "%#{search_san}%", "%#{search_san}%") + users = users.order("roles.value desc", "confirmed desc", :name) unless badge + users + end +end diff --git a/app/views/application/_md_editor_user.html.erb b/app/views/application/_md_editor_user.html.erb new file mode 100644 index 0000000..d799fce --- /dev/null +++ b/app/views/application/_md_editor_user.html.erb @@ -0,0 +1,8 @@ +
<%= f.submit "Update forum", class: "btn blue left" %>
<% end %><%= button_to "Delete forum", @forum, method: "delete", data: {confirm: "Delete forum forever?\nThreads won't be accessible!"}, class: "btn red right" %>
- \ No newline at end of file + diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index f09ea20..532484b 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -1,5 +1,7 @@ <% title "Forums" %> +<%= link_to "All threads", forumthreads_path, class: "btn blue right" %> +<%= f.submit "Create forum", class: "btn blue left" %>
-<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 60f3185..b232292 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -1,8 +1,13 @@ <%= link_to @forum.group, forumgroup_path(@forum.group) %> → <%= @forum %> -<%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %>
++ <%= link_to "New thread", new_forumthread_path(forum: @forum), class: "btn blue" %> +
<% end %> <% if @forum.role_read && @forum.role_write && @forum.role_write < @forum.role_read %> @@ -51,4 +56,4 @@| Forum | +<%= select_tag "forum", options_for_select(forums, params[:forum]), include_blank: "Search All Threads" %> | +
| Label | ++ <%= select_tag "label", options_for_select(label_list, params[:label]), include_blank: "Label" %> + | +
| Title | ++ <%= text_field_tag "title", params[:title], placeholder: "Search Titles" %> + | +
| Content | ++ <%= text_field_tag "content", params[:content], placeholder: "Search Contents" %> + | +
| Author | ++ <%= render partial: "md_editor_user", locals: {name: "author", content: params[:author]} %> + | +Replies | ++ <%= text_field_tag "reply", params[:reply], placeholder: "Search Replies" %> + | + +
| + <%= submit_tag "Go", class: "btn blue", style: "width:50px", name: nil %> + | +
Please <%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> to post a reply.
<% end %> -