Signed-off-by: Benjamin LAN-SUN-LUK <benjamin.lan-sun-luk(a)supinfo.com>
---
app/controllers/emails_controller.rb | 2 +-
app/controllers/home_contents_controller.rb | 22 ++++++++++++++++++++++
app/views/admin/index.html.erb | 1 +
app/views/emails/edit.html.erb | 2 +-
app/views/home_contents/edit.html.erb | 8 ++++++++
config/routes.rb | 1 +
test/functional/home_content_controller_test.rb | 8 ++++++++
7 files changed, 42 insertions(+), 2 deletions(-)
create mode 100644 app/controllers/home_contents_controller.rb
create mode 100644 app/views/home_contents/edit.html.erb
create mode 100644 test/functional/home_content_controller_test.rb
diff --git a/app/controllers/emails_controller.rb b/app/controllers/emails_controller.rb
index 13afd87..c9b1fdf 100644
--- a/app/controllers/emails_controller.rb
+++ b/app/controllers/emails_controller.rb
@@ -1,4 +1,4 @@
-# emails_controller.rb
+# emails_controller.rb
# Copyright (C) 2008, Darryl L. Pierce <mcpierce(a)gmail.com>
#
# This program is free software: you can redistribute it and/or modify it under
diff --git a/app/controllers/home_contents_controller.rb
b/app/controllers/home_contents_controller.rb
new file mode 100644
index 0000000..3a1fe0e
--- /dev/null
+++ b/app/controllers/home_contents_controller.rb
@@ -0,0 +1,22 @@
+# home_contents_controller.rb
+
+# Allow an admin to edit the content of the homepage
+class HomeContentsController < ApplicationController
+ def show
+ redirect_to :action => 'edit'
+ end
+
+ def edit
+ @content = ConfigProperty.fetch('text.homepage')
+ end
+
+ def update
+ if ConfigProperty.store('text.homepage', params['content'])
+ flash[:notice] = "Home page content updated"
+ end
+
+ respond_to do |format|
+ format.html { redirect_to :action => 'edit' }
+ end
+ end
+end
diff --git a/app/views/admin/index.html.erb b/app/views/admin/index.html.erb
index 7fbfdae..8fa22f8 100644
--- a/app/views/admin/index.html.erb
+++ b/app/views/admin/index.html.erb
@@ -1,3 +1,4 @@
<ul class="menulist">
<li class="menulist-item"><%= link_to "Configure Email",
admin_email_url %></li>
+ <li class="menulist-item"><%= link_to "Home page content",
admin_home_content_url %></li>
</ul>
diff --git a/app/views/emails/edit.html.erb b/app/views/emails/edit.html.erb
index 231127a..2eca356 100644
--- a/app/views/emails/edit.html.erb
+++ b/app/views/emails/edit.html.erb
@@ -1,4 +1,4 @@
-s<fieldset id="email-config">
+<fieldset id="email-config">
<legend>Email Configuration</legend>
<% form_tag admin_email_path, :method => :put do %>
<table class="edit">
diff --git a/app/views/home_contents/edit.html.erb
b/app/views/home_contents/edit.html.erb
new file mode 100644
index 0000000..5140dd3
--- /dev/null
+++ b/app/views/home_contents/edit.html.erb
@@ -0,0 +1,8 @@
+<fieldset id="home-content-config">
+ <legend>Home page content</legend>
+ <p style="color: green;"><%= flash[:notice] %></p>
+ <%= form_tag admin_home_content_path, :method => :put %>
+ <textarea cols="128" rows="32"
name="content"><%= @content %></textarea>
+ <%= submit_tag 'Save' %>
+ </form>
+</fieldset>
diff --git a/config/routes.rb b/config/routes.rb
index 6bf6212..ba069c8 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -20,6 +20,7 @@ ActionController::Routing::Routes.draw do |map|
map.resource :admin do |admin|
admin.resource :email
+ admin.resource :home_content
end
map.resources :projects
diff --git a/test/functional/home_content_controller_test.rb
b/test/functional/home_content_controller_test.rb
new file mode 100644
index 0000000..14be19d
--- /dev/null
+++ b/test/functional/home_content_controller_test.rb
@@ -0,0 +1,8 @@
+require 'test_helper'
+
+class HomeContentControllerTest < ActionController::TestCase
+ # Replace this with your real tests.
+ def test_truth
+ assert true
+ end
+end
--
1.5.6.3
Show replies by date
On Sun, Feb 15, 2009 at 12:48 PM, LAN-SUN-LUK Benjamin
<Benjamin.LAN-SUN-LUK(a)supinfo.com> wrote:
<snip>
Can you rebase and resend this patch?
--
Darryl L. Pierce <mcpierce(a)gmail.com>
Visit the Infobahn Offramp: <
http://mcpierce.multiply.com>
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant