summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMrYummy <elemental428@gmail.com>2017-05-28 17:46:39 -0400
committerMrYummy <elemental428@gmail.com>2017-06-18 13:11:36 -0400
commita24d26dd7c9c829b28732174ed5f5ff2d4448bfb (patch)
tree09b6a7e0b5ca523e092d17393ca68cfa66e2db57
parentdb3aea185b5d21a14e61ca3c1939083103cc4fb6 (diff)
Added Website Settings
-rw-r--r--Gemfile3
-rw-r--r--app/assets/stylesheets/dark.css.scss105
-rw-r--r--app/assets/stylesheets/mobi.css.scss15
-rw-r--r--app/assets/stylesheets/style.css.scss24
-rw-r--r--app/controllers/users_controller.rb11
-rw-r--r--app/helpers/application_helper.rb6
-rw-r--r--app/views/layouts/_head.html.erb9
-rw-r--r--app/views/layouts/application.html.erb11
-rw-r--r--app/views/users/edit.html.erb7
-rw-r--r--app/views/users/edit_website_settings.html.erb34
-rw-r--r--config/initializers/assets.rb1
-rw-r--r--db/migrate/20170320195301_add_utc_time_to_users.rb5
-rw-r--r--db/migrate/20170328100851_add_header_scroll_to_users.rb5
-rw-r--r--db/migrate/20170515200733_add_dark_to_users.rb5
-rw-r--r--db/schema.rb7
-rw-r--r--db/seeds.rb48
16 files changed, 236 insertions, 60 deletions
diff --git a/Gemfile b/Gemfile
index 4714ee3..a277484 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'
# 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/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 da15801..18042ad 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;
@@ -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;
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 27e89af..16f42d3 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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])
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'>
</iframe>")
end
-end \ No newline at end of file
+end
diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb
index 183a615..e6b5080 100644
--- a/app/views/layouts/_head.html.erb
+++ b/app/views/layouts/_head.html.erb
@@ -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> \ No newline at end of file
+</div>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index a0a5f83..e85d417 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -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> \ No newline at end of file
+</html>
diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb
index 5e63c00..133a69d 100644
--- a/app/views/users/edit.html.erb
+++ b/app/views/users/edit.html.erb
@@ -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>
diff --git a/app/views/users/edit_website_settings.html.erb b/app/views/users/edit_website_settings.html.erb
new file mode 100644
index 0000000..2fdeffb
--- /dev/null
+++ b/app/views/users/edit_website_settings.html.erb
@@ -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â„¢.
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
new file mode 100644
index 0000000..ea74dfd
--- /dev/null
+++ b/config/initializers/assets.rb
@@ -0,0 +1 @@
+Rails.application.config.assets.precompile += %w( dark.css )
diff --git a/db/migrate/20170320195301_add_utc_time_to_users.rb b/db/migrate/20170320195301_add_utc_time_to_users.rb
new file mode 100644
index 0000000..538357c
--- /dev/null
+++ b/db/migrate/20170320195301_add_utc_time_to_users.rb
@@ -0,0 +1,5 @@
+class AddUtcTimeToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :utc_time, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20170328100851_add_header_scroll_to_users.rb b/db/migrate/20170328100851_add_header_scroll_to_users.rb
new file mode 100644
index 0000000..0db36b1
--- /dev/null
+++ b/db/migrate/20170328100851_add_header_scroll_to_users.rb
@@ -0,0 +1,5 @@
+class AddHeaderScrollToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :header_scroll, :boolean, default: false
+ end
+end
diff --git a/db/migrate/20170515200733_add_dark_to_users.rb b/db/migrate/20170515200733_add_dark_to_users.rb
new file mode 100644
index 0000000..c4bf3cc
--- /dev/null
+++ b/db/migrate/20170515200733_add_dark_to_users.rb
@@ -0,0 +1,5 @@
+class AddDarkToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :dark, :boolean, default: false
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 353c482..0a29b6b 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -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
diff --git a/db/seeds.rb b/db/seeds.rb
index 06c8d10..7b7530d 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -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
-)