Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
use settings partial for setup page, plus other small refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Wright committed Feb 22, 2012
1 parent c17a424 commit c263194
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 69 deletions.
18 changes: 11 additions & 7 deletions app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 37,6 @@ def set_position

def settings
Settings.site_name = params[:site_name]
Settings.front_project = params[:front_project].to_i
@front_project = Project.find(Settings.front_project)
# make the front portfolio visible if it's not already
if !@front_project.visible?
@front_project.visible = true
@front_project.save
end
Settings.show_projects = params[:show_projects] || 'false'
Settings.blog_title = params[:blog_title]
Settings.about_title = params[:about_title]
Expand All @@ -54,6 47,17 @@ def settings
Settings.phone = params[:phone]
Settings.email = params[:email]
Settings.about_text = params[:about_text]

if params[:front_project]
Settings.front_project = params[:front_project].to_i
@front_project = Project.find(Settings.front_project)
# make the front portfolio visible if it's not already
if !@front_project.visible?
@front_project.visible = true
@front_project.save
end
end

if params[:initial_setup]
redirect_to :controller => 'projects', :action => 'new'
else
Expand Down
22 changes: 14 additions & 8 deletions app/views/admin/_settings.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 1,16 @@
<h2>Settings</h2>

<div class="settings">
<%= form_tag('/admin/settings') do %>
<div class="field">
<%= label_tag 'site_name', 'Site Name' %>
<%= text_field_tag 'site_name', Settings.site_name, :placeholder => 'John Doe\'s Portfolio' %>
</div>
<div class="field">
<%= label_tag 'front_project', 'Front Project' %>
<%= select_tag 'front_project', options_from_collection_for_select(@projects, 'id', 'title', Settings.front_project) %>
</div>
<span>This will be the name of your site, as displayed in the header and title bar.</span>
</div>
<% if !current_page?(admin_setup_path) %>
<div class="field">
<%= label_tag 'front_project', 'Front Project' %>
<%= select_tag 'front_project', options_from_collection_for_select(@projects, 'id', 'title', Settings.front_project) %>
</div>
<% end %>
<div class="field first">
<%= label_tag 'blog_title', 'Blog Section Title' %>
<%= text_field_tag 'blog_title', Settings.blog_title, :placeholder => 'Blog' %>
Expand Down Expand Up @@ -37,17 38,22 @@
<div class="field first">
<%= label_tag 'email' %>
<%= text_field_tag 'email', Settings.email %>
<span>Displayed on About page.</span>
</div>
<div class="field">
<%= label_tag 'phone' %>
<%= text_field_tag 'phone', Settings.phone %>
<span>Displayed on About page.</span>
</div>
<div id="bio-field" class="field text-field">
<%= label_tag 'about_text' %>
<%= text_area_tag 'about_text', Settings.about_text %>
</div>

<%= hidden_field_tag 'initial_setup', 'true' if current_page?(admin_setup_path) %>

<div class="field">
<%= submit_tag "Update Settings" %>
<%= submit_tag "Save Settings" %>
</div>
<% end %>
</div>
2 changes: 2 additions & 0 deletions app/views/admin/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 49,6 @@

</div>

<h2>Settings</h2>

<%= render 'settings' %>
2 changes: 2 additions & 0 deletions app/views/admin/password.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 1,5 @@
<% content_for :title do "Welcome" end %>

<h2>Welcome!</h2>

<p>There are a couple things we need to set up before you can start building portfolio. First off, please type in the password you'd like to use when accessing the admin sections of the site.</p>
Expand Down
58 changes: 4 additions & 54 deletions app/views/admin/setup.html.erb
Original file line number Diff line number Diff line change
@@ -1,57 1,7 @@
<% content_for :title do "Setup" end %>

<h2>Setup</h2>

<p>OK, now we need to get the basic settings. Don't worry, you can always edit these later.</p>
<p>OK! Now it's time to customize your portoflio. Don't worry, you can always edit this stuff later.</p>

<div class="settings">
<%= form_tag('/admin/settings') do %>
<div class="field">
<%= label_tag 'site_name', 'Site Name' %>
<%= text_field_tag 'site_name', Settings.site_name, :placeholder => 'John Doe\'s Portfolio' %>
<span>This will be the name of your site, as displayed in the header and title bar.</span>
</div>
<div class="field first">
<%= label_tag 'blog_title', 'Blog Section Title' %>
<%= text_field_tag 'blog_title', Settings.blog_title, :placeholder => 'Blog' %>
</div>
<div class="field">
<%= label_tag 'about_title', 'About Section Title' %>
<%= text_field_tag 'about_title', Settings.about_title, :placeholder => 'About' %>
</div>
<div class="field">
<%= label_tag 'contact_title', 'Contact Section Title' %>
<%= text_field_tag 'contact_title', Settings.contact_title, :placeholder => 'Contact' %>
</div>
<div class="field first check-field">
<%= check_box_tag 'show_blog', 'true', (Settings.show_blog == 'true') %>
<%= label_tag 'show_blog', 'Show Blog section?' %>
</div>
<div class="field check-field">
<%= check_box_tag 'show_about', 'true', (Settings.show_about == 'true') %>
<%= label_tag 'show_about', 'Show About section?' %>
</div>
<div class="field check-field">
<%= check_box_tag 'show_contact', 'true', (Settings.show_contact == 'true') %>
<%= label_tag 'show_contact', 'Show Contact section?' %>
</div>
<div class="field first">
<%= label_tag 'email' %>
<%= text_field_tag 'email', Settings.email %>
<span>Displayed on About page.</span>
</div>
<div class="field">
<%= label_tag 'phone' %>
<%= text_field_tag 'phone', Settings.phone %>
<span>Displayed on About page.</span>
</div>
<div id="bio-field" class="field text-field">
<%= label_tag 'about_text' %>
<%= text_area_tag 'about_text', Settings.about_text %>
</div>

<%= hidden_field_tag 'initial_setup', 'true' %>

<div class="field">
<%= submit_tag "Save Settings" %>
</div>
<% end %>
</div>
<%= render 'settings' %>

0 comments on commit c263194

Please sign in to comment.