Added Website Settings

This commit is contained in:
MrYummy
2017-05-28 17:46:39 -04:00
parent db3aea185b
commit a24d26dd7c
16 changed files with 236 additions and 60 deletions

View File

@@ -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'
# 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
end

View File

@@ -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;
}

View File

@@ -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;
}
}
}

View File

@@ -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;
@@ -454,6 +466,7 @@ blockquote p {
}
.md_editor {
.field_container {
position: relative;
@@ -461,7 +474,7 @@ blockquote p {
position: absolute;
top: 1em;
left: 1em;
z-index: 10;
z-index: 0;
}
.editor_field {
@@ -671,6 +684,13 @@ tr.spacer {
color: #ddd;
}
&.variable-size {
background: #4096ee;
@media only screen and (max-width: 500px) {
font-size: 9px;
}
}
&.blue {
background: #4096ee;

View File

@@ -157,9 +157,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, :badge, :confirmed])
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])
@@ -241,6 +241,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])

View File

@@ -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'>
</iframe>")
end
end
end

View File

@@ -1,4 +1,9 @@
<div id="head">
<% head = "head_top" %>
<% if current_user != nil && current_user.header_scroll == true %>
<% head = "head_scroll" %>
<% end %>
<div id="<%= head %>">
<div id="menu">
<%= link_to "", root_path, id: "logo" %>
<ul>
@@ -41,4 +46,4 @@
<% end %>
</div>
</div>
</div>
</div>

View File

@@ -5,6 +5,9 @@
<meta name="viewport" content="initial-scale=1,maximum-scale=1">
<meta name="description" content="Redstoner is a creative minecraft server made for redstoners">
<%= stylesheet_link_tag "application", :media => "all" %>
<% if current_user.try(:dark) == true %>
<%= stylesheet_link_tag "dark", :media => "all" %>
<% end %>
<%= csrf_meta_tags %>
<%= favicon_link_tag "favicon.ico" %>
<%= javascript_include_tag "https://cdn.rawgit.com/jomo/ago.js/v0.0.1/ago.min.js", crossorigin: :anonymous, integrity: "sha256-xw0JUUdbuZQCVO+QScoxrlEsD4nZGCjMRh9PP8GLhcY=" %>
@@ -14,7 +17,11 @@
</head>
<body>
<%= render partial: "/layouts/head" %>
<div id="main-content" class="<%= yield(:main_class) %>">
<% content = "main-content" %>
<% if current_user.try(:header_scroll) == true %>
<% content = "main-content-scroll" %>
<% end %>
<div id="<%=content%>" class="<%=yield(:main_class) %>">
<% if alert %>
<div class='flash alert'><%= alert %></div>
<% end %>
@@ -25,4 +32,4 @@
</div>
<%= render partial: "/layouts/footer" %>
</body>
</html>
</html>

View File

@@ -75,10 +75,11 @@
</tbody>
</table>
<p><%= f.submit "Save profile", class: "btn blue left", disabled: (!@user.confirmed? && @user.is?(current_user)) %></p>
<p><%= f.submit "Save profile", class: "btn variable-size left", disabled: (!@user.confirmed? && @user.is?(current_user)) %></p>
<p>
<%= link_to "Edit login details", edit_login_user_path(@user), class: "btn blue right" %>
<%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn blue right" %>
<%= link_to "Edit login details", edit_login_user_path(@user), class: "btn variable-size right" %>
<%= link_to "Notification settings", edit_notifications_user_path(@user), class: "btn variable-size right" %>
<%= link_to "Website settings", edit_website_settings_user_path(@user), class: "btn variable-size right" %>
</p>
<div class="clear"></div>

View File

@@ -0,0 +1,34 @@
<% title "Edit Website Settings: #{@user.name}" %>
<%= link_to @user.name, @user %> → Edit Website Settings
<h1>Edit Website Settings</h1>
<%= form_for @user do |f| %>
<table>
<tbody>
<tr>
<td>Header moves with scrolling (Experimental - do not report bugs)</td>
<td>
<%= f.check_box :header_scroll %>
</td>
</tr>
<tr>
<td>Show exact UTC times</td>
<td>
<%= f.check_box :utc_time %>
</td>
</tr>
<tr>
<td>Dark theme*</td>
<td>
<%= f.check_box :dark %>
</td>
</tr>
</tbody>
</table>
<p><%= f.submit "Save changes", class: "btn blue left" %></p>
<div class="clear"></div>
<% end %>
<br><br><br>
*Warning: If as a result to enabling this style your eyes get infected with a severe case of eye cancer, we are not reliable for any damage. Please contact your doctor in advance to ensure that in case of infection you will be treated accordingly. Quality theme brought to you by Redempt™.

View File

@@ -0,0 +1 @@
Rails.application.config.assets.precompile += %w( dark.css )

View File

@@ -0,0 +1,5 @@
class AddUtcTimeToUsers < ActiveRecord::Migration
def change
add_column :users, :utc_time, :boolean, default: false
end
end

View File

@@ -0,0 +1,5 @@
class AddHeaderScrollToUsers < ActiveRecord::Migration
def change
add_column :users, :header_scroll, :boolean, default: false
end
end

View File

@@ -0,0 +1,5 @@
class AddDarkToUsers < ActiveRecord::Migration
def change
add_column :users, :dark, :boolean, default: false
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170409135858) do
ActiveRecord::Schema.define(version: 20170515200733) do
create_table "blogposts", force: :cascade do |t|
t.string "title", limit: 191
@@ -133,6 +133,7 @@ ActiveRecord::Schema.define(version: 20170409135858) do
t.boolean "confirmed", default: false
t.datetime "last_seen"
t.integer "role_id", limit: 4, null: false
t.integer "badge_id"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "mail_own_thread_reply", default: true
@@ -140,7 +141,9 @@ ActiveRecord::Schema.define(version: 20170409135858) do
t.boolean "mail_own_blogpost_comment", default: true
t.boolean "mail_other_blogpost_comment", default: true
t.boolean "mail_mention", default: true
t.integer "badge_id"
t.boolean "header_scroll", default: false
t.boolean "utc_time", default: false
t.boolean "dark", default: false
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree

View File

@@ -36,7 +36,10 @@ deleted_user = User.create!(
skype_public: true,
last_ip: "0.0.0.0",
confirmed: true,
last_seen: Time.utc(0).to_datetime
last_seen: Time.utc(0).to_datetime,
header_scroll: false,
utc_time: false,
dark: false
)
deleted_user.update_attribute(:ign, "Steve")
@@ -47,46 +50,9 @@ User.create!(
password: "123456789", # high seructity!
password_confirmation: "123456789",
role: Role.get(:superadmin),
header_scroll: false,
utc_time: false,
dark: false
badge: Badge.get(:donor),
confirmed: true
)
User.create!(
uuid: "7f52491ab5d64c11b4a43806db47a101",
ign: "YummyRedstone",
email: "yummy@example.com",
password: "123456789", # high seructity!
password_confirmation: "123456789",
role: Role.get(:admin),
badge: Badge.get(:lead),
confirmed: true
)
User.create!(
uuid: "d2693e9193e14e3f929ff38e1ce8df03",
ign: "Pepich1851",
email: "pepe@example.com",
password: "123456789", # high seructity!
password_confirmation: "123456789",
role: Role.get(:superadmin),
badge: Badge.get(:retired),
confirmed: true
)
User.create!(
uuid: "c69f8316c60a4f8ca922bda933e01acd",
ign: "Doomblah",
email: "doom@example.com",
password: "123456789", # high seructity!
password_confirmation: "123456789",
role: Role.get(:normal),
badge: Badge.get(:developer),
confirmed: true
)
User.create!(
uuid: "b85a91b558b0474da2a42d5dd025f9e5",
ign: "Futsy",
email: "futsy@example.com",
password: "123456789", # high seructity!
password_confirmation: "123456789",
role: Role.get(:mod),
badge: Badge.get(:none),
confirmed: true
)