| @@ -1,4 +1,9 @@ | |||||
| class AdminController < ApplicationController | class AdminController < ApplicationController | ||||
| def index | def index | ||||
| end | end | ||||
| def update | |||||
| # respond to form data... | |||||
| render 'index' | |||||
| end | |||||
| end | end | ||||
| @@ -1,2 +1,8 @@ | |||||
| module AdminHelper | module AdminHelper | ||||
| SETTINGS = [ | |||||
| {:key => :site_name, :label => 'Site name'}, | |||||
| {:key => :corporation, :label => 'Corporation'}, | |||||
| {:key => :description, :label => 'Home page description', :textarea => true}, | |||||
| {:key => :copyright, :label => 'Copyright'}, | |||||
| ] | |||||
| end | end | ||||
| @@ -1,6 +1,16 @@ | |||||
| class AdminSetting < ActiveRecord::Base | class AdminSetting < ActiveRecord::Base | ||||
| def self.get(key) | def self.get(key) | ||||
| self.find_by(key: key).value | |||||
| Rails.cache.fetch("admin_setting/#{key}") do | |||||
| self.find_by(key: key).value | |||||
| end | |||||
| end | |||||
| def self.set(key, value) | |||||
| setting = self.find_by(key: key) | |||||
| setting.update(value: value) | |||||
| Rails.cache.write("admin_setting/#{key}") do | |||||
| value | |||||
| end | |||||
| end | end | ||||
| end | end | ||||
| @@ -1,4 +1,23 @@ | |||||
| <% provide(:title, 'Admin') %> | <% provide(:title, 'Admin') %> | ||||
| <h1>Admin#index</h1> | <h1>Admin#index</h1> | ||||
| <p>Find me in app/views/admin/index.html.erb</p> | |||||
| <p><%= link_to 'Home', controller: 'tools', action: 'index' %></p> | |||||
| <%= form_tag do %> | |||||
| <table> | |||||
| <% AdminHelper::SETTINGS.each do |s| %> | |||||
| <tr> | |||||
| <td><%= label_tag(s[:key], s[:label]) %></td> | |||||
| <% if s[:textarea] %> | |||||
| <td><%= text_area_tag(s[:key], AdminSetting.get(s[:key].to_s), size: "60x5") %></td> | |||||
| <% else %> | |||||
| <td><%= text_field_tag(s[:key], AdminSetting.get(s[:key].to_s), size: 40) %></td> | |||||
| <% end %> | |||||
| </tr> | |||||
| <% end %> | |||||
| <tr> | |||||
| <td colspan="2"><%= submit_tag('Update') %></td> | |||||
| </tr> | |||||
| </table> | |||||
| <% end %> | |||||
| @@ -1,17 +1,17 @@ | |||||
| <!DOCTYPE html> | <!DOCTYPE html> | ||||
| <html> | <html> | ||||
| <head> | <head> | ||||
| <title><%= get_title(yield(:title)) %></title> | |||||
| <%= stylesheet_link_tag 'application', media: 'all' %> | |||||
| <%= javascript_include_tag 'application' %> | |||||
| <%= csrf_meta_tags %> | |||||
| <title><%= get_title(yield(:title)) %></title> | |||||
| <%= stylesheet_link_tag 'application', media: 'all' %> | |||||
| <%= javascript_include_tag 'application' %> | |||||
| <%= csrf_meta_tags %> | |||||
| </head> | </head> | ||||
| <body> | <body> | ||||
| <%= render "shared/header" %> | |||||
| </div> | |||||
| <div id="content"> | |||||
| <%= yield %> | |||||
| </div> | |||||
| <%= render "shared/footer" %> | |||||
| <%= render "shared/header" %> | |||||
| </div> | |||||
| <div id="content"> | |||||
| <%= yield %> | |||||
| </div> | |||||
| <%= render "shared/footer" %> | |||||
| </body> | </body> | ||||
| </html> | </html> | ||||
| @@ -1,9 +1,9 @@ | |||||
| <div id="footer"> | <div id="footer"> | ||||
| <p> | |||||
| Copyright © <%= get_copyright_year %> <%= get_copyright_holders %> | |||||
| • | |||||
| Running Calefaction <%= Calefaction::Version::VERSION_STRING %> | |||||
| • | |||||
| <a href="//eveonline.com">EVE Online</a> and all related trademarks are property of <a href="//ccpgames.com">CCP hf</a>. | |||||
| </p> | |||||
| <p> | |||||
| Copyright © <%= get_copyright_year %> <%= get_copyright_holders %> | |||||
| • | |||||
| Running Calefaction <%= Calefaction::Version::VERSION_STRING %> | |||||
| • | |||||
| <a href="//eveonline.com">EVE Online</a> and all related trademarks are property of <a href="//ccpgames.com">CCP hf</a>. | |||||
| </p> | |||||
| </div> | </div> | ||||
| @@ -1,3 +1,3 @@ | |||||
| <div id="header"> | <div id="header"> | ||||
| <!-- --> | |||||
| <!-- --> | |||||
| </div> | </div> | ||||
| @@ -1,14 +1,14 @@ | |||||
| <h1>Tools#index</h1> | <h1>Tools#index</h1> | ||||
| <p> | <p> | ||||
| Users: | |||||
| <%= link_to "Signup", controller: "users", action: "create" %> | |||||
| • | |||||
| <%= link_to "Login", controller: "users", action: "login" %> | |||||
| Users: | |||||
| <%= link_to "Signup", controller: "users", action: "create" %> | |||||
| • | |||||
| <%= link_to "Login", controller: "users", action: "login" %> | |||||
| </p> | </p> | ||||
| <p> | <p> | ||||
| Admin: | |||||
| <%= link_to "Admin", controller: "admin", action: "index" %> | |||||
| Admin: | |||||
| <%= link_to "Admin", controller: "admin", action: "index" %> | |||||
| </p> | </p> | ||||
| <p>Tools: ...</p> | <p>Tools: ...</p> | ||||
| @@ -1,10 +1,11 @@ | |||||
| Rails.application.routes.draw do | Rails.application.routes.draw do | ||||
| root 'tools#index' | root 'tools#index' | ||||
| get '/signup' => 'users#create' | |||||
| get '/login' => 'users#login' | |||||
| get '/signup' => 'users#create' | |||||
| get '/login' => 'users#login' | |||||
| get '/admin' => 'admin#index' | |||||
| get '/admin' => 'admin#index' | |||||
| post '/admin' => 'admin#update' | |||||
| # Example of named route that can be invoked with purchase_url(id: product.id) | # Example of named route that can be invoked with purchase_url(id: product.id) | ||||
| # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase | # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase | ||||