Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

added page metadata to ansuz core

  • Loading branch information...
Josh Adams
Josh Adams committed Nov 14, 2008
1 parent 7ce5dfe commit cb4cdb654ac5e0808c9657469aabf1a57fde364c
@@ -0,0 +1 @@
0.0.3
@@ -0,0 +1,27 @@
class Admin::PageMetadatasController < Admin::BaseController
before_filter :load_page
before_filter :load_page_metadata, :only => [:edit, :update]

protected
def load_page
@page = Page.find(params[:page_id])
end

def load_page_metadata
@page_metadata = @page.page_metadata
end

public
def edit
end

def update
if @page_metadata.update_attributes(params[:page_metadata])
flash[:notice] = "Metadata was updated successfully."
redirect_to edit_admin_page_path(@page)
else
flash.now[:error] = "There was a problem updating the metadata."
render :action => 'edit'
end
end
end
@@ -21,9 +21,13 @@

class Page < ActiveRecord::Base
acts_as_tree :order => 'page_order'
before_save :check_page_type, :check_page_order
attr_protected :page_number, :pages

has_many :page_plugins
has_one :page_metadata

before_save :check_page_type, :check_page_order
before_save :ensure_page_metadata

def linked_children
children.select{|x| x.linked? }
@@ -164,4 +168,10 @@ def check_page_order
self.page_order = self.last_page + 1
end

def create_page_metadata
unless self.page_metadata
self.page_metadata = PageMetadata.new
end
end

end
@@ -0,0 +1,2 @@
class PageMetadata < ActiveRecord::Base
end
@@ -13,3 +13,6 @@
<p><%= submit_tag 'Log in' %></p>
<% end -%>
</div>
<script type="text/javascript">
jQuery('div.login form').focusFirstField();
</script>
@@ -0,0 +1,17 @@
<%= title "Edit Metadata for page: #{@page}" %>

<% content_for :sidebar do %>
<%= link_to "Back to Page", admin_page_path(@page), :class => 'button icon back' %>
<% end %>

<% form_for [:admin, :page, @page_metadata] do |f| %>
<table class='form-table'>
<%= form_row "Title", f.text_field(:title) -%>
<%= form_row "Subject", f.text_field(:subject) -%>
<%= form_row "Description", f.text_area(:description) -%>
<%= form_row "Publisher", f.text_field(:publisher) -%>
<%= form_row "Rights", f.text_field(:rights) -%>
</table>
<br />
<%= submit_tag "Update Metadata" %>
<% end %>
@@ -2,6 +2,7 @@

<% content_for :sidebar do -%>
<%= link_to "Manage Pages", admin_pages_path, :class => 'button icon back' %>
<%= link_to "Edit Metadata", edit_admin_page_page_metadata_path(@page), :class => 'button icon pencil' %>
<br />
<% form_remote_tag :url => admin_page_path(@page),
:update => 'main',
@@ -19,9 +19,9 @@
<%= stylesheet_link_tag 'form-tables' %>
<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
<%= stylesheet_link_tag 'ui.tabs.css' %>
<%= javascript_include_tag :defaults -%>
<%= javascript_include_tag 'jquery' -%>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag :defaults -%>
<%= javascript_include_tag 'jquery.growl.js', 'ansuz/growls' %>
<%= javascript_include_tag 'jquery-ui-personalized-1.6rc2.min.js' %>
<%= javascript_include_tag 'show_and_hide' %>
@@ -18,9 +18,9 @@
<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
<%= stylesheet_link_tag 'clickmenu' %>
<%= stylesheet_link_tag 'ui.tabs.css' %>
<%= javascript_include_tag :defaults -%>
<%= javascript_include_tag 'jquery' -%>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag :defaults -%>
<%= javascript_include_tag 'jquery.growl.js', 'ansuz/growls' %>
<%= javascript_include_tag 'jquery-ui-personalized-1.6rc2.min.js' %>
<%= javascript_include_tag 'show_and_hide' %>
@@ -13,7 +13,7 @@
map.resources :users
map.resources :tags
map.namespace :admin do |admin|
admin.resources :pages, :member => [:shift_order]
admin.resources :pages, :member => [:shift_order], :has_one => [:page_metadata]
admin.resources :page_plugins
admin.resources :plugins
admin.resource :account
@@ -0,0 +1,18 @@
class CreatePageMetadatas < ActiveRecord::Migration
def self.up
create_table :page_metadatas do |t|
t.integer :page_id
t.string :title
t.string :subject
t.text :description
t.string :publisher
t.string :rights

t.timestamps
end
end

def self.down
drop_table :page_metadatas
end
end
@@ -1,2 +1,15 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

// This will provide a plugin to allow you to focus the first input field
// of a given form on page load
// So you can do $('#form1').focusFirstField();
(function(jQuery){
jQuery.fn.focusFirstField = function(){
$this = this;
$this.find(":text:visible:enabled").filter(function(){
return jQuery(this).parents(":hidden").size() == 0;
}).slice(0,1).focus();
return this;
}
})(jQuery);
@@ -0,0 +1,17 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

one:
page_id: 1
title: MyString
subject: MyString
description: MyText
publisher: MyString
rights: MyString

two:
page_id: 1
title: MyString
subject: MyString
description: MyText
publisher: MyString
rights: MyString
@@ -0,0 +1,8 @@
require 'test_helper'

class PageMetadataTest < ActiveSupport::TestCase
# Replace this with your real tests.
def test_truth
assert true
end
end

0 comments on commit cb4cdb6

Please sign in to comment.
You can’t perform that action at this time.