diff --git a/app/assets/stylesheets/screen.css.scss b/app/assets/stylesheets/screen.css.scss index 664b1e3..530c8f7 100644 --- a/app/assets/stylesheets/screen.css.scss +++ b/app/assets/stylesheets/screen.css.scss @@ -290,9 +290,22 @@ and (min-width: 0px) //TODO &[type=submit] { margin: 0; } + option { + padding: 0.5em; + &:hover { + background: #0f0; + color: #00f; + } + &:nth-child(even) { + background: #eee; + } + &:nth-child(odd) { + background: #ccc; + } + } } - input[type=text], input[type=email], input[type=password], textarea { + input[type=text], input[type=email], input[type=password], input[type=number], textarea, select { background: #ddd; border: none; display: block; @@ -352,13 +365,13 @@ and (min-width: 0px) //TODO float: left; label { display: block; - padding: 0 0 4px 0; - margin: 0 4px 4px; - height: 17px; + padding: 0.5em; } } #form_inputs { - + input, select, textarea { + width: 400px; + } } .profile-action { @@ -397,6 +410,9 @@ and (min-width: 0px) //TODO &.red { background: #ee4040; } + &.right { + float: right; + } &:hover { box-shadow: 0 0 5px #095fb7 inset; color: #fff; @@ -468,7 +484,7 @@ and (min-width: 0px) //TODO .header { background: #ddd; border-radius: 5px 5px 0 0; - padding: 5px 10px; + padding: 0.5em; border-bottom: 1px solid #ccc; } .forums { @@ -478,7 +494,7 @@ and (min-width: 0px) //TODO .forum { display: block; font-weight: bold; - padding: 5px 10px; + padding: 0.5em; border-bottom: 1px solid #ddd; } } diff --git a/app/controllers/blogposts_controller.rb b/app/controllers/blogposts_controller.rb index ba20e5f..86adbb3 100644 --- a/app/controllers/blogposts_controller.rb +++ b/app/controllers/blogposts_controller.rb @@ -29,7 +29,7 @@ class BlogpostsController < ApplicationController def create if mod? - @post = Blogpost.new(params[:blogpost]) + @post = Blogpost.new(params[:blogpost] ? params[:blogpost].slice(:title, :content) : {}) @post.user_author = current_user if @post.save redirect_to @post, notice: 'Post has been created.' diff --git a/app/controllers/forumgroups_controller.rb b/app/controllers/forumgroups_controller.rb index 4f41a7f..bacadab 100644 --- a/app/controllers/forumgroups_controller.rb +++ b/app/controllers/forumgroups_controller.rb @@ -1,9 +1,46 @@ class ForumgroupsController < ApplicationController + def index - @groups = Forumgroup.all.sort_by{|s| s[:position]} + @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 - redirect_to forumgroups_path + "#forum-#{params[:id]}" + redirect_to forumgroups_path + "#forums-#{params[:id]}" end + + def new + if admin? + @group = Forumgroup.new + else + flash[:alert] = "You are not allowed to create forums." + redirect_to forumgroups_path + end + end + + def create + if admin? + @group = Forumgroup.new(params[:forumgroup]) + if @group.save + flash[:notice] = "Forums created." + redirect_to @group + else + flash[:alert] = "Something went wrong" + render :new + end + else + flash[:alert] = "You are not allowed to create forums." + redirect_to forumgroups_path + end + end + + + end \ No newline at end of file diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index d7242cd..2ecb551 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -8,4 +8,31 @@ class ForumsController < ApplicationController @threads = @forum.forumthreads end + def new + if admin? + @group = Forumgroup.find(params[:forumgroup_id]) + @forum = Forum.new(forumgroup: @group) + else + flash[:alert] = "You are not allowed to create a forum." + redirect_to forumgroups_path + end + end + + def create + if admin? + @forum = Forum.new(params[:forum]) + @forum.forumgroup = Forumgroup.find(params[:forumgroup_id]) + if @forum.save + flash[:notice] = "Forum created." + redirect_to @forum + else + flash[:alert] = "Something went wrong" + render :new + end + else + flash[:alert] = "You are not allowed to create a forum." + redirect_to forums_path + end + end + end \ No newline at end of file diff --git a/app/controllers/youtube.regex b/app/controllers/youtube.regex new file mode 100644 index 0000000..855c624 --- /dev/null +++ b/app/controllers/youtube.regex @@ -0,0 +1,6 @@ +[yt](729o_Xwg1WU) + +\[yt\]\(([a-zA-Z0-9\-_]+)\) + + +https://www.youtube.com/embed/{id}?theme=light&iv_load_policy=3&showinfo=1&showsearch=0&rel=0&modestbranding&hd=1&autohide=1 \ No newline at end of file diff --git a/app/models/forum.rb b/app/models/forum.rb index 5011c4c..4ace5db 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -1,6 +1,10 @@ class Forum < ActiveRecord::Base belongs_to :forumgroup has_many :forumthreads + belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id" + belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" + + attr_accessible :name, :position, :role_read, :role_write, :role_read_id, :role_write_id, :forumgroup, :forumgroup_id def to_s name diff --git a/app/models/forumgroup.rb b/app/models/forumgroup.rb index daca97b..55577f5 100644 --- a/app/models/forumgroup.rb +++ b/app/models/forumgroup.rb @@ -1,5 +1,13 @@ class Forumgroup < ActiveRecord::Base has_many :forums + belongs_to :role_read, class_name: "Role", foreign_key: "role_read_id" + belongs_to :role_write, class_name: "Role", foreign_key: "role_write_id" + accepts_nested_attributes_for :forums + + attr_accessible :name, :position, :role_read, :role_write, :role_read_id, :role_write_id + + validates_presence_of :name, :position + validates_length_of :name, in: 2..20 def to_s name diff --git a/app/models/role.rb b/app/models/role.rb index a01f301..7785c41 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -35,4 +35,10 @@ class Role < ActiveRecord::Base end end + def self.all_from(role) + Role.all.select do |r| + r >= role + end + end + end \ No newline at end of file diff --git a/app/views/blogposts/edit.html.erb b/app/views/blogposts/edit.html.erb index e94e620..3b85d52 100644 --- a/app/views/blogposts/edit.html.erb +++ b/app/views/blogposts/edit.html.erb @@ -6,5 +6,5 @@ <%= f.submit "Update Post", :id => "edit_create_post", class: "btn blue" %> <% end %>
New forum group
+<%= simple_form_for @group do |f|%> +New forum
+<%= simple_form_for [@group, @forum] do |f|%> +<%= @forum.name %>
<%= link_to root_path do %>- Home
<% end %>
+ <%= link_to users_path do %>- Users
<% end %>
<%= link_to root_path do %>- Info
<% end %>
<%= link_to forumgroups_path do %>- Forums
<% end %>
<%= link_to root_path do %>- Donate
<% end %>
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb
index cf68775..a6be509 100644
--- a/app/views/sessions/new.html.erb
+++ b/app/views/sessions/new.html.erb
@@ -1,5 +1,5 @@
<%= label_tag :email %>
@@ -7,9 +7,9 @@
- <%= text_field_tag :email %>
- <%= password_field_tag :password %>
+ <%= text_field_tag :email, nil, placeholder: "email@example.com" %>
+ <%= password_field_tag :password, nil, placeholder: "••••••" %>
- <%= submit_tag "Log in" %>
+ <%= submit_tag "Log in", class: "btn blue" %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index d512b9b..68ca11e 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -1,4 +1,4 @@
-<%= link_to "Your profile", current_user %> → Edit
+<%= link_to (@user.is?(current_user) ? "Your profile" : @user.name), current_user %> → Edit
- Skype username
<%= f.input :skype, label: false, placeholder: "Skype username", disabled: !((@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role)) %>
- <%= f.input :skype_public, label: false, as: :radio_buttons, collection: [['all users', false], ['only staff', true]], input_html: { disabled: !((@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role)) } %>
-
+
+
+ Show Skype to
+
+
+ <%= f.input :skype_public, label: false, as: :select, collection: [["Staff only", false], ["All users", true]], include_blank: false, input_html: { disabled: !((@user.is?(current_user) && confirmed?) || (mod? && current_user.role >= @user.role)) } %>
+
YouTube username
@@ -61,8 +65,13 @@
- <%= f.submit "Save profile", disabled: @user.unconfirmed? %>
+ <%= f.submit "Save profile", class: "btn blue", disabled: @user.unconfirmed? %>
<% if @user.unconfirmed? %>
- Please confirm your email adress first.
+ <% if @user.is?(current_user) %>
+ Please confirm your email adress first!
+ <% else %>
+ This user has not confirmed his email!
+ <% end %>
<% end %>
+ <%= link_to "Cancel", @user, class: "btn red right" %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb
index 8233d39..9d5b240 100644
--- a/app/views/users/new.html.erb
+++ b/app/views/users/new.html.erb
@@ -1,10 +1,19 @@
-
+ <%= f.label :name, "Display name" %>
+ <%= f.label :ign, "Minecraft name" %>
+ <%= f.label :email, "Email" %>
+ <%= f.label :password, "Password" %>
+ <%= f.label :password_confirmation, "Confirm" %>
+
+
+ <%= f.input :name, placeholder: "John" %>
+ <%= f.input :ign, placeholder: "johndoe_1337" %>
+ <%= f.input :email, placeholder: "johndoe@example.com" %>
+ <%= f.input :password, placeholder: "••••••" %>
+ <%= f.input :password_confirmation, placeholder: "••••••" %>
+
+ <%= f.submit "Sign up", class: "btn blue" %>
<% end %>
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 377b533..5697824 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -16,13 +16,8 @@ Site::Application.routes.draw do
end
end
resources :forumgroups, :path => '/forums' do
- member do
- resources :forums, :path => 'f' do
- member do
- resources :forumthreads, :path => 't', :as => 'threads' do
- end
- end
- end
+ resources :forums, :path => 'f' do
+ resources :forumthreads, :path => 't', :as => 'threads'
end
end
diff --git a/db/migrate/00000000000005_create_forumgroups.rb b/db/migrate/00000000000005_create_forumgroups.rb
index 942ad26..4c06033 100644
--- a/db/migrate/00000000000005_create_forumgroups.rb
+++ b/db/migrate/00000000000005_create_forumgroups.rb
@@ -3,8 +3,9 @@ class CreateForumgroups < ActiveRecord::Migration
create_table :forumgroups do |t|
t.string :name
t.integer :position
- t.integer :read_permission
- t.integer :write_permission
+
+ t.references :role_read
+ t.references :role_write
end
end
end
\ No newline at end of file
diff --git a/db/migrate/00000000000006_create_forums.rb b/db/migrate/00000000000006_create_forums.rb
index 77b5439..61a7141 100644
--- a/db/migrate/00000000000006_create_forums.rb
+++ b/db/migrate/00000000000006_create_forums.rb
@@ -3,8 +3,9 @@ class CreateForums < ActiveRecord::Migration
create_table :forums do |t|
t.string :name
t.integer :position
- t.integer :read_permission
- t.integer :write_permission
+
+ t.references :role_read
+ t.references :role_write
t.references :forumgroup
end
diff --git a/db/migrate/20130922181339_add_sessions_table.rb b/db/migrate/00000000000008_add_sessions_table.rb
similarity index 100%
rename from db/migrate/20130922181339_add_sessions_table.rb
rename to db/migrate/00000000000008_add_sessions_table.rb
diff --git a/db/schema.rb b/db/schema.rb
index bdcd2e5..add6f97 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20130922181339) do
+ActiveRecord::Schema.define(:version => 8) do
create_table "blogposts", :force => true do |t|
t.string "title"
@@ -34,15 +34,15 @@ ActiveRecord::Schema.define(:version => 20130922181339) do
create_table "forumgroups", :force => true do |t|
t.string "name"
t.integer "position"
- t.integer "read_permission"
- t.integer "write_permission"
+ t.integer "role_read_id"
+ t.integer "role_write_id"
end
create_table "forums", :force => true do |t|
t.string "name"
t.integer "position"
- t.integer "read_permission"
- t.integer "write_permission"
+ t.integer "role_read_id"
+ t.integer "role_write_id"
t.integer "forumgroup_id"
end
Log in
-Not a member? <%= link_to "Join us here", signup_path %>!
+Not a member? <%= link_to "Join us", signup_path %>!
<%= form_tag login_path do |f| %>Edit profile
<%= simple_form_for @user do |f| %> @@ -32,15 +32,19 @@- Show to... + Skype username
Register
+Sign up
<%= simple_form_for @user do |f| %> - <%= f.input :name, label: "Display Name" %> - <%= f.input :ign, label: "Case sensitive Minecraft name" %> - <%= f.input :email %> - <%= f.input :password %> - <%= f.input :password_confirmation %> - <%= f.submit "Register" %> +