forums
This commit is contained in:
@@ -330,14 +330,17 @@ and (min-width: 0px) //TODO
|
||||
}
|
||||
}
|
||||
|
||||
.input {
|
||||
height: 3em;
|
||||
}
|
||||
input[type=text], input[type=email], input[type=password], input[type=number], textarea, select {
|
||||
background: #ddd;
|
||||
border: none;
|
||||
display: block;
|
||||
height: 3em;
|
||||
margin: 0 0 1px 0;
|
||||
padding: 0.5em 1em;
|
||||
width: 100%;
|
||||
display: block;
|
||||
}
|
||||
|
||||
input, select, textarea {
|
||||
@@ -374,14 +377,14 @@ and (min-width: 0px) //TODO
|
||||
}
|
||||
|
||||
.field_with_errors {
|
||||
input {
|
||||
&[type=text], &[type=email], &[type=password] {
|
||||
input, select, textarea {
|
||||
border: 1px solid #f00;
|
||||
box-shadow: 0 0 5px #faa inset;
|
||||
}
|
||||
}
|
||||
.error {
|
||||
color: #f60;
|
||||
display: inline;
|
||||
margin-left: 0.5em;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,6 +521,10 @@ and (min-width: 0px) //TODO
|
||||
#forum_groups {
|
||||
.group {
|
||||
margin: 10px 0;
|
||||
&:hover .editlink {
|
||||
opacity: 1;
|
||||
margin-right: 0;
|
||||
}
|
||||
.header {
|
||||
background: #ddd;
|
||||
border-radius: 5px 5px 0 0;
|
||||
|
||||
@@ -6,7 +6,7 @@ class BlogpostsController < ApplicationController
|
||||
|
||||
def show
|
||||
@post = Blogpost.find(params[:id])
|
||||
@comment = Comment.new(:blogpost => @post)
|
||||
@comment = Comment.new(blogpost: @post)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
class ForumgroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@groups = Forumgroup.all
|
||||
if current_user
|
||||
@groups.select! do |g|
|
||||
g.role_read == nil || g.role_read <= current_user.role
|
||||
end
|
||||
else
|
||||
@groups.select!{|g| g.role_read == nil}
|
||||
end
|
||||
@groups.sort_by{|g| g[:position]}
|
||||
redirect_to forums_path
|
||||
end
|
||||
|
||||
def show
|
||||
redirect_to forumgroups_path + "#forums-#{params[:id]}"
|
||||
redirect_to forums_path + "#forums-#{params[:id]}"
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -21,7 +20,7 @@ class ForumgroupsController < ApplicationController
|
||||
@group = Forumgroup.new
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create forums."
|
||||
redirect_to forumgroups_path
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,11 +1,23 @@
|
||||
class ForumsController < ApplicationController
|
||||
def index
|
||||
redirect_to :forumgroups
|
||||
@groups = Forumgroup.all
|
||||
if current_user
|
||||
@groups.select! do |g|
|
||||
g.role_read.nil? || g.role_read <= current_user.role
|
||||
end
|
||||
else
|
||||
@groups.select!{|g| g.role_read == nil}
|
||||
end
|
||||
@groups.sort_by{|g| g[:position]}
|
||||
end
|
||||
|
||||
def show
|
||||
@forum = Forum.find(params[:id])
|
||||
@threads = @forum.forumthreads
|
||||
if @forum.role_read.nil? || current_user && @forum.role_read <= current_user.role
|
||||
@threads = @forum.forumthreads.reverse
|
||||
else
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
@@ -14,7 +26,7 @@ class ForumsController < ApplicationController
|
||||
@forum = Forum.new(forumgroup: @group)
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create a forum."
|
||||
redirect_to forumgroups_path
|
||||
redirect_to forums_path
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,4 +3,20 @@ class ForumthreadsController < ApplicationController
|
||||
f = Forum.find(params[:id])
|
||||
redirect_to forum_path(f.forumgroup, f)
|
||||
end
|
||||
|
||||
def new
|
||||
@forum = Forum.find(params[:id])
|
||||
if @forum && current_user && (@forum.group.role_read.nil? || @forum.group.role_read <= current_user.role) && (@forum.role_read.nil? || @forum.role_read <= current_user.role)
|
||||
@thread = Forumthread.new(forum: @forum)
|
||||
else
|
||||
flash[:alert] = "You are not allowed to create a new thread here!"
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
flash[:alert] = "Not yet ;("
|
||||
redirect_to forum_path(params[:id])
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -3,8 +3,10 @@ class SessionsController < ApplicationController
|
||||
|
||||
def new
|
||||
if current_user
|
||||
redirect_to current_user
|
||||
flash[:alert] = "You are already logged in!"
|
||||
redirect_to current_user
|
||||
else
|
||||
cookies[:return_path] = params[:return_path] if params[:return_path]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,23 +25,27 @@ class SessionsController < ApplicationController
|
||||
user.save
|
||||
if user.disabled?
|
||||
flash[:alert] = "Your account has been disabled!"
|
||||
redirect_to login_path
|
||||
elsif user.banned?
|
||||
flash[:alert] = "You are banned!"
|
||||
redirect_to user
|
||||
else
|
||||
session[:user_id] = user.id
|
||||
flash[:alert] = "Remember to validate your email! Your account might be deleted" if user.unconfirmed?
|
||||
redirect_to root_path, :notice => "Logged in!"
|
||||
flash[:alert] = "Remember to validate your email! Your account may be deleted soon!" if user.unconfirmed?
|
||||
flash[:notice] = "Logged in!"
|
||||
end
|
||||
else
|
||||
flash[:alert] = "You're doing it wrong!"
|
||||
render action: 'new'
|
||||
return
|
||||
end
|
||||
else
|
||||
redirect_to current_user
|
||||
flash[:alert] = "You are already logged in!"
|
||||
end
|
||||
if cookies[:return_path]
|
||||
redirect_to cookies[:return_path]
|
||||
cookies.delete(:return_path)
|
||||
else
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
@@ -3,6 +3,11 @@ class Forumthread < ActiveRecord::Base
|
||||
belongs_to :user_author, class_name: "User", foreign_key: "user_author_id"
|
||||
belongs_to :user_editor, class_name: "User", foreign_key: "user_editor_id"
|
||||
|
||||
attr_accessible :name, :content, :sticky, :locked, :user_author, :user_editor, :forum
|
||||
|
||||
validates_presence_of :name
|
||||
validates_presence_of :content
|
||||
|
||||
def to_s
|
||||
name
|
||||
end
|
||||
|
||||
1
app/views/forumgroups/edit.html.erb
Normal file
1
app/views/forumgroups/edit.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<h1>Not yet</h1>
|
||||
@@ -3,6 +3,7 @@
|
||||
<div class="group" id="forums-<%= group.id %>">
|
||||
<div class="header">
|
||||
<%= group.name %>
|
||||
<%= link_to "edit", edit_forumgroup_path(group), class: "editlink" if admin? %>
|
||||
</div>
|
||||
|
||||
<div class="forums">
|
||||
@@ -1,20 +1,12 @@
|
||||
<%= link_to "Forums", forumgroups_path %> → <%= link_to @forum.group, "#{forumgroups_path}#forums-#{@forum.group.id}" %> → <%= link_to @forum %>
|
||||
<%= link_to "Forums", forumgroups_path %> → <%= link_to @forum.group, @forum.group %> → <%= link_to @forum %>
|
||||
<h1><%= @forum.name %></h1>
|
||||
<%= link_to "New thread", new_forumthread_path, class: "btn blue" %>
|
||||
<div id="forum_threads">
|
||||
<% @threads.each do |thread| %>
|
||||
<div class="group" id="thread-<%= thread.id %>">
|
||||
<div class="header">
|
||||
<%= thread.name %>
|
||||
</div>
|
||||
|
||||
<div class="forums">
|
||||
<% thread.forums.sort_by{|s| s[:position]}.each do |f| %>
|
||||
<div class="forum">
|
||||
<%= link_to f.name, f %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
18
app/views/forumthreads/new.html.erb
Normal file
18
app/views/forumthreads/new.html.erb
Normal file
@@ -0,0 +1,18 @@
|
||||
<%= link_to @forum.group, @forum.group %> → <%= link_to @forum, @forum %> → New thread
|
||||
<h1>New thread</h1>
|
||||
<%= simple_form_for @thread do |f|%>
|
||||
<div id="form_labels">
|
||||
<%= f.label :title %>
|
||||
<%= f.label :sticky if mod? %>
|
||||
<%= f.label :locked if mod? %>
|
||||
<%= f.label :content, "Text" %>
|
||||
</div>
|
||||
<div id="form_inputs">
|
||||
<%= f.input :title, placeholder: "Title" %>
|
||||
<%= f.input :sticky, as: :select, collection: [["No", false], ["Yes", true]], include_blank: false if mod? %>
|
||||
<%= f.input :locked, as: :select, collection: [["No", false], ["Yes", true]], include_blank: false if mod? %>
|
||||
<%= f.input :content, placeholder: "Text" %>
|
||||
</div>
|
||||
<%= f.submit "Create forum", class: "btn blue" %><br>
|
||||
Yea i know this is ugly :D
|
||||
<% end %>
|
||||
@@ -10,7 +10,7 @@
|
||||
</span>
|
||||
<%= link_to image_tag(avatar_url(current_user.id, 32), :class => "avatar"), current_user %>
|
||||
<% else %>
|
||||
<%= link_to "Log in", login_path, :action => "new" %> | <%= link_to "Sign up", signup_path %>
|
||||
<%= link_to "Log in", login_path(return_path: request.env['PATH_INFO']), action: "new" %> | <%= link_to "Sign up", signup_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<%= javascript_include_tag "application" %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="mobile-info">We don't have a mobile style yet. It might look shitty.<br>Tip: Turn your device to landscape.</div>
|
||||
<div id="mobile-info">We don't have a mobile style yet. It might look shitty.<br>Tip: Hold your device in landscape mode.</div>
|
||||
<%= render "/layouts/head" %>
|
||||
<div id="main-content">
|
||||
<%= "<div id='alert' class='flash'>#{alert}</div>".html_safe if alert %>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Site::Application.routes.draw do
|
||||
|
||||
resources :blogposts, :path => '/blog' do
|
||||
resources :blogposts, path: '/blog' do
|
||||
resources :comments
|
||||
end
|
||||
|
||||
@@ -15,9 +15,13 @@ Site::Application.routes.draw do
|
||||
get 'unbecome'
|
||||
end
|
||||
end
|
||||
resources :forumgroups, :path => '/forums' do
|
||||
resources :forums, :path => 'f' do
|
||||
resources :forumthreads, :path => 't', :as => 'threads'
|
||||
|
||||
resources :forums, path: 'forums', as: 'forums' do
|
||||
collection do
|
||||
resources :forumgroups, path: 'groups'
|
||||
end
|
||||
member do
|
||||
resources :forumthreads, path: 'threads'
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,5 +34,5 @@ Site::Application.routes.draw do
|
||||
|
||||
post 'paypal' => 'paypal#create'
|
||||
|
||||
root :to => 'blogposts#index'
|
||||
root to: 'blogposts#index'
|
||||
end
|
||||
Reference in New Issue
Block a user