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

Commit

Permalink
added menu system back, we need it for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Adams committed Feb 14, 2009
1 parent 1229c05 commit e755210
Show file tree
Hide file tree
Showing 15 changed files with 183 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application.rb
Expand Up @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
before_filter :login_from_cookie, :setup_plugin_nav, :set_layout_variables, :load_menu
around_filter :inhibit_retardase

helper :all, :testimonials, :site_settings, :form_builder
helper :all, :site_settings

theme :get_theme_setting

Expand Down
14 changes: 1 addition & 13 deletions config/routes.rb
@@ -1,22 +1,10 @@
ActionController::Routing::Routes.draw do |map|
map.from_plugin :ansuz_photo_album
map.from_plugin :ansuz_blog
map.from_plugin :ansuz_savage_beast
map.from_plugin :ansuz_content_section
map.from_plugin :ansuz_user_manager
map.from_plugin :ansuz_menu_system
map.from_plugin :ansuz_theme_repository
map.from_plugin :ansuz_theme_installer
map.from_plugin :ansuz_scrollable_content
map.from_plugin :ansuz_testimonials
map.from_plugin :ansuz_form_builder
map.from_plugin :ansuz_feed_reader
map.from_plugin :ansuz_jskit
map.from_plugin :ansuz_twitterati
map.from_plugin :ansuz_database_dumper
map.from_plugin :ansuz_user_system
#map.from_plugin :ansuz_plugin_media_player
map.from_plugin :ansuz_mephisto_xmlrpc
map.from_plugin :ansuz_menu_system

map.resources :tags
map.resources :users
Expand Down
13 changes: 13 additions & 0 deletions vendor/plugins/ansuz_menu_system/README
@@ -0,0 +1,13 @@
AnsuzContentSection
===================

Introduction goes here.


Example
=======

Example goes here.


Copyright (c) 2008 [name of plugin creator], released under the MIT license
22 changes: 22 additions & 0 deletions vendor/plugins/ansuz_menu_system/Rakefile
@@ -0,0 +1,22 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

desc 'Default: run unit tests.'
task :default => :test

desc 'Test the ansuz_content_section plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end

desc 'Generate documentation for the ansuz_content_section plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'AnsuzContentSection'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end
@@ -0,0 +1,56 @@
class Admin::MenuEntriesController < Admin::BaseController
unloadable # This is required if you subclass a controller provided by the base rails app

layout 'admin'
before_filter :load_menu_entry, :only => [:show, :edit, :update, :destroy]
before_filter :load_new_menu_entry, :only => [:new, :create]
before_filter :load_menu_entries, :only => [:index]

protected
def load_menu_entry
@menu_entry = Ansuz::JAdams::MenuEntry.find(params[:id])
end

def load_new_menu_entry
@menu_entry = Ansuz::JAdams::MenuEntry.new(params[:menu_entry])
end

def load_menu_entries
@menu_entries = Ansuz::JAdams::MenuEntry.find(:all, :order => 'position')
end
public
def new
end

def create
if @menu_entry.save
flash[:notice] = "Menu Entry was created successfully."
redirect_to admin_menu_entries_path
else
flash.now[:error] = "There was a problem creating the menu entry."
render :action => 'new'
end
end

def show
end

def edit
end

def update
if @menu_entry.update_attributes(params[:menu_entry])
flash[:notice] = "Menu Entry has been updated."
redirect_to admin_menu_entries_path
else
flash.now[:error] = "There was a problem updating the Menu Entry. Please try again."
render :action => 'edit'
end
end

def destroy
@menu_entry.destroy
flash[:notice] = "Menu Entry was deleted."
redirect_to admin_menu_entries_path
end
end
@@ -0,0 +1,14 @@
module Ansuz
module 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

def to_s
name
end
end
end
end
@@ -0,0 +1 @@
<%= plugin_module.contents -%>
@@ -0,0 +1 @@
This is the edit view
@@ -0,0 +1,7 @@
<div class='fullwidth'>
<table class='form-table'>
<%= form_row "Name", f.text_field(:name) -%>
<%= form_row "Link", f.text_field(:link) -%>
</table>
</div>
<br />
@@ -0,0 +1,8 @@
<%= title "Edit Menu Entry: #{@menu_entry}" -%>
<% content_for :sidebar do -%>
<%= link_to "All Menu Entries", admin_menu_entries_path, :class => 'button icon back' -%>
<% 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,32 @@
<%= title "Menu Entries" -%>
<% content_for :sidebar do -%>
<%= link_to "New Menu Entry", new_admin_menu_entry_path, :class => 'button icon add' -%>
<div class='note'>
OK, so this is odd. Basically, you can add freeform menu entries here. If you want to embed the 'pages' menu, you can add a menu entry with the name 'pages' and the url 'special.' <%= link_to "This is very kludgy and will be changed later.", "http://ansuz.lighthouseapp.com/projects/15780-ansuz/tickets/7-make-the-menu-editor-plugin-ui-a-lot-nicer" %>
</div>
<% end -%>
<div class='fullwidth'>
<table class='subdued'>
<thead>
<tr>
<th>Name</th>
<th>URL</th>
<th></th>
</tr>
</thead>
<tbody>
<% @menu_entries.each do |menu_entry| -%>
<tr class='<%= cycle('odd', 'even') -%>'>
<td><%= link_to h(menu_entry.name), edit_admin_menu_entry_path(menu_entry) -%></td>
<td><%= menu_entry.link -%></td>
<td>
<ul class='admin_actions'>
<li><%= link_to famfamfam_icon("pencil"), edit_admin_menu_entry_path(menu_entry) -%></li>
<li><%= link_to famfamfam_icon("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>
</div>
@@ -0,0 +1,8 @@
<%= title "New Menu Entry" -%>
<% content_for :sidebar do -%>
<%= link_to "All Menu Entries", admin_menu_entries_path, :class => 'button icon back' -%>
<% 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
1 change: 1 addition & 0 deletions vendor/plugins/ansuz_menu_system/init.rb
@@ -0,0 +1 @@
Ansuz::PluginManagerInstance.register_admin_menu_entry('Manage', 'Menu', '/admin/menu_entries')
3 changes: 3 additions & 0 deletions vendor/plugins/ansuz_menu_system/routes.rb
@@ -0,0 +1,3 @@
namespace :admin do |admin|
admin.resources :menu_entries
end

0 comments on commit e755210

Please sign in to comment.