From 5db01b7517e196b64efa4d2c3df9a528d7c32118 Mon Sep 17 00:00:00 2001 From: Josh Adams Date: Wed, 17 Sep 2008 19:43:38 -0500 Subject: [PATCH] worked on menu entries quite a bit, as well as fixed jquery onflict in default-pink theme --- config/routes.rb | 1 + .../default-pink/layouts/application.html.erb | 4 +- themes/default-pink/layouts/page.html.erb | 4 +- .../admin/menu_entries_controller.rb | 2 +- .../app/models/menu_entry.rb | 4 ++ .../menu_entries/_content_section.html.erb | 1 + .../views/admin/menu_entries/_edit.html.erb | 1 + .../views/admin/menu_entries/_form.html.erb | 2 + .../views/admin/menu_entries/edit.html.erb | 8 ++++ .../views/admin/menu_entries/index.html.erb | 27 +++++++++++ .../app/views/admin/menu_entries/new.html.erb | 8 ++++ .../db/migrate/001_create_menu_entries.rb | 15 +++++++ .../admin/photo_albums_controller.rb | 22 +++++++++ .../controllers/admin/photos_controller.rb | 45 +++++++++++++++++++ .../app/models/photo_album.rb | 4 +- .../admin/photo_albums/_photo_album.html.erb | 11 +++++ .../views/admin/photo_albums/show.html.erb | 10 +++++ .../app/views/admin/photos/_form.html.erb | 3 ++ .../app/views/admin/photos/edit.html.erb | 5 +++ .../app/views/admin/photos/new.html.erb | 5 +++ vendor/plugins/ansuz_photo_album/routes.rb | 4 +- 21 files changed, 180 insertions(+), 6 deletions(-) create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_content_section.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_edit.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_form.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/edit.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/index.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/new.html.erb create mode 100644 vendor/plugins/ansuz_menu_system/db/migrate/001_create_menu_entries.rb create mode 100644 vendor/plugins/ansuz_photo_album/app/controllers/admin/photo_albums_controller.rb create mode 100644 vendor/plugins/ansuz_photo_album/app/controllers/admin/photos_controller.rb create mode 100644 vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/_photo_album.html.erb create mode 100644 vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/show.html.erb create mode 100644 vendor/plugins/ansuz_photo_album/app/views/admin/photos/_form.html.erb create mode 100644 vendor/plugins/ansuz_photo_album/app/views/admin/photos/edit.html.erb create mode 100644 vendor/plugins/ansuz_photo_album/app/views/admin/photos/new.html.erb diff --git a/config/routes.rb b/config/routes.rb index 7d2d005..b30f2b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/themes/default-pink/layouts/application.html.erb b/themes/default-pink/layouts/application.html.erb index c3aa019..67399e7 100644 --- a/themes/default-pink/layouts/application.html.erb +++ b/themes/default-pink/layouts/application.html.erb @@ -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' -%> diff --git a/themes/default-pink/layouts/page.html.erb b/themes/default-pink/layouts/page.html.erb index fef9287..96116ce 100644 --- a/themes/default-pink/layouts/page.html.erb +++ b/themes/default-pink/layouts/page.html.erb @@ -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' -%> diff --git a/vendor/plugins/ansuz_menu_system/app/controllers/admin/menu_entries_controller.rb b/vendor/plugins/ansuz_menu_system/app/controllers/admin/menu_entries_controller.rb index 1f4304e..a171fa2 100644 --- a/vendor/plugins/ansuz_menu_system/app/controllers/admin/menu_entries_controller.rb +++ b/vendor/plugins/ansuz_menu_system/app/controllers/admin/menu_entries_controller.rb @@ -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' diff --git a/vendor/plugins/ansuz_menu_system/app/models/menu_entry.rb b/vendor/plugins/ansuz_menu_system/app/models/menu_entry.rb index 5d2c05f..47c096e 100644 --- a/vendor/plugins/ansuz_menu_system/app/models/menu_entry.rb +++ b/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 diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_content_section.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_content_section.html.erb new file mode 100644 index 0000000..87d2c62 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_content_section.html.erb @@ -0,0 +1 @@ +<%= plugin_module.contents -%> diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_edit.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_edit.html.erb new file mode 100644 index 0000000..8e893a6 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_edit.html.erb @@ -0,0 +1 @@ +This is the edit view diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_form.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_form.html.erb new file mode 100644 index 0000000..67a5d38 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/_form.html.erb @@ -0,0 +1,2 @@ +Name: <%= f.text_field(:name) -%>
+Link: <%= f.text_field(:link) -%>
diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/edit.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/edit.html.erb new file mode 100644 index 0000000..4c2d8f7 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/edit.html.erb @@ -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 -%> diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/index.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/index.html.erb new file mode 100644 index 0000000..b9de712 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/index.html.erb @@ -0,0 +1,27 @@ +<%= title "Menu Entries" -%> +<% content_for :sidebar do -%> + <%= link_to "New Menu Entry", new_admin_menu_entry_path -%> +<% end -%> + + + + + + + + + + <% @menu_entries.each do |menu_entry| -%> + '> + + + + + <% end -%> + +
NameURLActions
<%= link_to h(menu_entry.name), admin_menu_entry_path(menu_entry) -%><%= menu_entry.link -%> +
    +
  • <%= link_to "Edit", edit_admin_menu_entry_path(menu_entry) -%>
  • +
  • <%= link_to "Delete", admin_menu_entry_path(menu_entry), :method => :delete, :confirm => "Are you sure you want to delete this menu entry?" -%>
  • +
+
diff --git a/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/new.html.erb b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/new.html.erb new file mode 100644 index 0000000..b5c75b9 --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/app/views/admin/menu_entries/new.html.erb @@ -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 -%> diff --git a/vendor/plugins/ansuz_menu_system/db/migrate/001_create_menu_entries.rb b/vendor/plugins/ansuz_menu_system/db/migrate/001_create_menu_entries.rb new file mode 100644 index 0000000..a15a93c --- /dev/null +++ b/vendor/plugins/ansuz_menu_system/db/migrate/001_create_menu_entries.rb @@ -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 diff --git a/vendor/plugins/ansuz_photo_album/app/controllers/admin/photo_albums_controller.rb b/vendor/plugins/ansuz_photo_album/app/controllers/admin/photo_albums_controller.rb new file mode 100644 index 0000000..3446129 --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/controllers/admin/photo_albums_controller.rb @@ -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 diff --git a/vendor/plugins/ansuz_photo_album/app/controllers/admin/photos_controller.rb b/vendor/plugins/ansuz_photo_album/app/controllers/admin/photos_controller.rb new file mode 100644 index 0000000..9ed97ab --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/controllers/admin/photos_controller.rb @@ -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 diff --git a/vendor/plugins/ansuz_photo_album/app/models/photo_album.rb b/vendor/plugins/ansuz_photo_album/app/models/photo_album.rb index e9fc71d..1d17d93 100644 --- a/vendor/plugins/ansuz_photo_album/app/models/photo_album.rb +++ b/vendor/plugins/ansuz_photo_album/app/models/photo_album.rb @@ -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 diff --git a/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/_photo_album.html.erb b/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/_photo_album.html.erb new file mode 100644 index 0000000..8185acf --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/_photo_album.html.erb @@ -0,0 +1,11 @@ + diff --git a/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/show.html.erb b/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/show.html.erb new file mode 100644 index 0000000..1547ec1 --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/views/admin/photo_albums/show.html.erb @@ -0,0 +1,10 @@ +<%= title "Photo Album" -%> +<% content_for :sidebar do -%> + <%= link_to "Add Photo", new_admin_photo_album_photo_path(@photo_album) -%> +<% end -%> +

Photos

+ diff --git a/vendor/plugins/ansuz_photo_album/app/views/admin/photos/_form.html.erb b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/_form.html.erb new file mode 100644 index 0000000..6f28f32 --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/_form.html.erb @@ -0,0 +1,3 @@ +Title: <%= f.text_field(:title) -%>
+Caption: <%= f.text_area(:caption) -%>
+File: <%= f.file_field(:photo_album_photo_image) -%>
diff --git a/vendor/plugins/ansuz_photo_album/app/views/admin/photos/edit.html.erb b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/edit.html.erb new file mode 100644 index 0000000..74950da --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/edit.html.erb @@ -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 -%> diff --git a/vendor/plugins/ansuz_photo_album/app/views/admin/photos/new.html.erb b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/new.html.erb new file mode 100644 index 0000000..09d5012 --- /dev/null +++ b/vendor/plugins/ansuz_photo_album/app/views/admin/photos/new.html.erb @@ -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 -%> diff --git a/vendor/plugins/ansuz_photo_album/routes.rb b/vendor/plugins/ansuz_photo_album/routes.rb index 590509c..ed76e74 100644 --- a/vendor/plugins/ansuz_photo_album/routes.rb +++ b/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