Skip to content
This repository has been archived by the owner on Aug 15, 2018. It is now read-only.

Commit

Permalink
worked on menu entries quite a bit, as well as fixed jquery onflict i…
Browse files Browse the repository at this point in the history
…n default-pink theme
  • Loading branch information
Josh Adams committed Sep 18, 2008
1 parent 80c3aaa commit 5db01b7
Show file tree
Hide file tree
Showing 21 changed files with 180 additions and 6 deletions.
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -4,6 +4,7 @@
map.from_plugin :savage_beast
map.from_plugin :ansuz_content_section
map.from_plugin :ansuz_user_manager
map.from_plugin :ansuz_menu_system

map.resources :users
map.resources :tags
Expand Down
4 changes: 3 additions & 1 deletion themes/default-pink/layouts/application.html.erb
Expand Up @@ -14,7 +14,9 @@
<%= stylesheet_link_tag 'base' -%>
<%= stylesheet_link_tag 'sprite' -%>
<%= stylesheet_link_tag 'lightbox' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jqModal', 'jquery.growl.js' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery' -%>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag 'jqModal', 'jquery.growl.js' -%>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
Expand Down
4 changes: 3 additions & 1 deletion themes/default-pink/layouts/page.html.erb
Expand Up @@ -15,7 +15,9 @@
<%= stylesheet_link_tag 'sprite' -%>
<%= stylesheet_link_tag 'lightbox' -%>
<%= stylesheet_link_tag 'acts_as_taggable_stylesheet' %>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery', 'jqModal', 'jquery.growl.js', 'ansuz/growls' -%>
<%= javascript_include_tag :defaults, 'effects', 'builder', 'lightbox', 'niftycube', 'handle_rounded_corners', 'jquery' -%>
<%= javascript_tag "jQuery.noConflict();" -%>
<%= javascript_include_tag 'jqModal', 'jquery.growl.js', 'ansuz/growls' -%>
<!--[if lt IE 7.]><%= javascript_include_tag 'pngfix.js' %><![endif]-->
</head>
<body>
Expand Down
Expand Up @@ -41,7 +41,7 @@ def edit
def update
if @menu_entry.update_attributes(params[:menu_entry])
flash[:notice] = "Menu Entry has been updated."
redirect_to admin_menu_entry_path(@menu_entry)
redirect_to admin_menu_entries_path
else
flash.now[:error] = "There was a problem updating the Menu Entry. Please try again."
render :action => 'edit'
Expand Down
4 changes: 4 additions & 0 deletions vendor/plugins/ansuz_menu_system/app/models/menu_entry.rb
@@ -1,6 +1,10 @@
class Ansuz
class JAdams
class MenuEntry < ActiveRecord::Base
acts_as_tree :order => 'position'
def self.root_entries
Ansuz::JAdams::MenuEntry.find(:all, :conditions => "parent_id IS NULL", :order => 'position')
end
end
end
end
@@ -0,0 +1 @@
<%= plugin_module.contents -%>
@@ -0,0 +1 @@
This is the edit view
@@ -0,0 +1,2 @@
Name: <%= f.text_field(:name) -%><br />
Link: <%= f.text_field(:link) -%><br />
@@ -0,0 +1,8 @@
<%= title "Edit Menu Entry: #{@menu_entry}" -%>
<% content_for :sidebar do -%>
<%= link_to "All Menu Entries", admin_menu_entries_path -%>
<% end -%>
<% form_for :menu_entry, :url => admin_menu_entry_path(@menu_entry), :html => { :method => :put } do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<%= submit_tag("Update Menu Entry") -%> or <%= link_to "Cancel", admin_menu_entries_path -%>
<% end -%>
@@ -0,0 +1,27 @@
<%= title "Menu Entries" -%>
<% content_for :sidebar do -%>
<%= link_to "New Menu Entry", new_admin_menu_entry_path -%>
<% end -%>
<table class='subdued'>
<thead>
<tr>
<th>Name</th>
<th>URL</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @menu_entries.each do |menu_entry| -%>
<tr class='<%= cycle('odd', 'even') -%>'>
<td><%= link_to h(menu_entry.name), admin_menu_entry_path(menu_entry) -%></td>
<td><%= menu_entry.link -%></td>
<td>
<ul class='admin_actions'>
<li><%= link_to "Edit", edit_admin_menu_entry_path(menu_entry) -%></li>
<li><%= link_to "Delete", admin_menu_entry_path(menu_entry), :method => :delete, :confirm => "Are you sure you want to delete this menu entry?" -%></li>
</ul>
</td>
</tr>
<% end -%>
</tbody>
</table>
@@ -0,0 +1,8 @@
<%= title "New Menu Entry" -%>
<% content_for :sidebar do -%>
<%= link_to "All Menu Entries", admin_menu_entries_path -%>
<% end -%>
<% form_for :menu_entry, :url => admin_menu_entries_path do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<%= submit_tag("Create Menu Entry") -%> or <%= link_to "Cancel", admin_menu_entries_path -%>
<% end -%>
@@ -0,0 +1,15 @@
class CreateMenuEntries < ActiveRecord::Migration
def self.up
create_table "menu_entries", :force => true do |t|
t.string "name"
t.string "link"
t.integer "position"
t.integer "parent_id"
t.timestamps
end
end

def self.end
drop_table "menu_entries"
end
end
@@ -0,0 +1,22 @@
class Admin::PhotoAlbumsController < Admin::BaseController
unloadable # This is required if you subclass a controller provided by the base rails app

before_filter :load_photo_album, :only => [:show, :update]
before_filter :load_photos, :only => [:show]
layout 'admin'

protected
def load_photo_album
@photo_album = Ansuz::JAdams::PhotoAlbum.find(params[:id])
end

def load_photos
@photos = @photo_album.photos
end
public
def show
end

def update
end
end
@@ -0,0 +1,45 @@
class Admin::PhotosController < Admin::BaseController
unloadable # This is required if you subclass a controller provided by the base rails app

before_filter :load_photo_album
before_filter :load_new_photo, :only => [:new, :create]
before_filter :load_photo, :only => [:show, :edit, :update, :destroy]
protected
def load_photo_album
@photo_album = Ansuz::JAdams::PhotoAlbum.find(params[:photo_album_id])
end

def load_new_photo
@photo = @photo_album.photos.build(params[:photo])
end

def load_photo
@photo = @photo_album.photos.find(params[:id])
end

public
def new
end

def create
if @photo.save
flash[:notice] = "The photo was saved successfully."
redirect_to admin_photo_album_path(@photo_album)
else
render :action => 'new'
end
end

def edit
end

def update
if @photo.update_attributes(params[:photo])
flash[:notice] = "Photo was updated succesffully."
redirect_to admin_photo_album_path(@photo_album)
else
flash.now[:error] = "There was a problem updating the photo."
render :action => "edit"
end
end
end
4 changes: 2 additions & 2 deletions vendor/plugins/ansuz_photo_album/app/models/photo_album.rb
Expand Up @@ -7,11 +7,11 @@ class PhotoAlbum < ActiveRecord::Base
has_many :photos, :class_name => "Ansuz::JAdams::PhotoAlbumPhoto", :dependent => :destroy

def edit_path
"/photo_albums/#{id}"
"/admin/photo_albums/#{id}"
end

def self.view_partial
"/photo_albums/photo_album"
"/admin/photo_albums/photo_album"
end
end
end
Expand Down
@@ -0,0 +1,11 @@
<ul class='photos'>
<% plugin_module.photos.each do |photo| -%>
<li>
<%= link_to image_tag(photo.photo_album_photo_image.url(:thumb)),
photo.photo_album_photo_image.url(:large),
:rel => "lightbox[#{plugin_module.id}]",
:title => "<h2>#{photo.title}</h2>#{photo.caption}"
-%>
</li>
<% end -%>
</ul>
@@ -0,0 +1,10 @@
<%= title "Photo Album" -%>
<% content_for :sidebar do -%>
<%= link_to "Add Photo", new_admin_photo_album_photo_path(@photo_album) -%>
<% end -%>
<h3>Photos</h3>
<ul class='photos'>
<% @photos.each do |photo| -%>
<li><%= link_to image_tag(photo.photo_album_photo_image.url(:thumb)), edit_admin_photo_album_photo_path(@photo_album, photo) -%></li>
<% end -%>
</ul>
@@ -0,0 +1,3 @@
Title: <%= f.text_field(:title) -%><br />
Caption: <%= f.text_area(:caption) -%><br />
File: <%= f.file_field(:photo_album_photo_image) -%><br />
@@ -0,0 +1,5 @@
<%= title "Edit Photo" -%>
<% form_for :photo, :url => admin_photo_album_photo_path(@photo.photo_album, @photo), :html => { :multipart => true, :method => :put } do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<%= submit_tag "Update photo" -%> or <%= link_to "Cancel", admin_photo_album_photo_path(@photo_album, @photo) -%>
<% end -%>
@@ -0,0 +1,5 @@
<%= title "New Photo" -%>
<% form_for :photo, :url => admin_photo_album_photos_path(@photo_album), :html => { :multipart => true } do |f| -%>
<%= render :partial => 'form', :locals => { :f => f } -%>
<%= submit_tag "Add photo" -%> or <%= link_to "Cancel", admin_photo_album_path(@photo_album) -%>
<% end -%>
4 changes: 3 additions & 1 deletion vendor/plugins/ansuz_photo_album/routes.rb
@@ -1 +1,3 @@
resources :photo_albums, :has_many => [:photos]
namespace :admin do |admin|
admin.resources :photo_albums, :has_many => [:photos]
end

0 comments on commit 5db01b7

Please sign in to comment.