Skip to content

Commit

Permalink
Improved documentation now is online here http://api.lipsiasoft.com
Browse files Browse the repository at this point in the history
Refactored text_field, text_area, password_field helpers
Refactored country_select helper
Refactored ext_date_select, ext_datetime_select helpers
  • Loading branch information
Davide D'Agostino authored and Davide D'Agostino committed Feb 25, 2009
1 parent 053e263 commit 56ef3d8
Show file tree
Hide file tree
Showing 33 changed files with 1,277 additions and 402 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
pkg/*
pkg/*
doc/*
8 changes: 7 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2008-02-25
* Improved documentation now is online here http://api.lipsiasoft.com
* Refactored text_field, text_area, password_field helpers
* Refactored country_select helper
* Refactored ext_date_select, ext_datetime_select helpers

2008-02-24
* Rename Js app from Lipsiadmin.app to Backend.app
* Added the possibility to reuse pages/froms/grids in windows.
Expand All @@ -19,7 +25,7 @@
* Added a pdf builder for actionmailer
* Added method missing in ActiveRecord to intercept calls to non-localized methods (eg. name instead of name_cz)
* Added utility scopes for paginate, include, search
* Added a new literal method for prevent json to "strignify" javascripts funtctions (eg. "function() { alert('me')}".to_lt)
* Added a new literal method for prevent json to "strignify" javascripts funtctions (eg. "function() { alert('me')}".to_l)
* Added a new module for escape utf8 chars for servers that don't have java with utf8 fonts (it's used by pdf builder)

2008-05-21
Expand Down
45 changes: 27 additions & 18 deletions README
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
Created by Davide D'Agostino on 2008-01-11.
Copyright 2009 Lipsiasoft s.r.l. All rights reserved.

Released under the MIT license

==Lipsiadmin


Lipsiadmin is a new revolutionary admin for your projects.

Is developped by http://www.lipsiasoft.com that use it from 2 years in production enviroments.
Expand All @@ -17,34 +11,49 @@ because the aim of developper wose build in a agile way web/site apps so we use
intelligent way a mixin of <tt>old</tt> html and new ajax functions,
for example ext manage the layout of page, grids, tree and errors, but form are in html code.

Author:: Davide D'Agostino
Copyright:: Copyright (c) 2009 Lipsiasoft s.r.l. (http://www.lipsiasoft.com)
License:: MIT License (http://www.opensource.org/licenses/mit-license.php)
Api Documentation:: http://api.lipsiasoft.com

==Requirements

Rails 2.0
Haml 2.0

==Installation

script/plugin install git://github.com/Lipsiasoft/lipsiadmin.git
script/plugin install git://github.com/Lipsiasoft/lipsiadmin.git

The version 2.9 version is an alpha relase and the gem will be aviable from 3.0

In future you can simply do:

in config/environments.rb
config.gem "lipsiadmin"

then (if you don't have it already)

$ rake gems:install

==Examples

now run script/generate and you can see some like:

Installed Generators
Builtin: controller, integration_test, mailer, migration, model, observer, performance_test, plugin, resource, scaffold, session_migration
Lipsiadmin: attachment, backend, backend_page, pdf

script/generate backend # Generate the base admin
script/generate backend_page yourmodel # Generate a "scaffold" for your model
script/generate attachment # Generate the an attachments
script/generate pdf PdfName # Generate a new pdf document
Installed Generators
Builtin: controller, integration_test, mailer, migration, model, etc..
Lipsiadmin: attachment, backend, backend_page, pdf

==Remember
So you can do:

That now Lipsiadmin use your current locale of environment for generate localized pages
$ script/generate backend # Generate the base admin
$ script/generate backend_page yourmodel # Generate a "scaffold" for your model
$ script/generate attachment # Generate the an attachments
$ script/generate pdf PdfName # Generate a new pdf document

==Contribute

Please contribute in coding, patch, and submitting translation.
Please contribute in coding, patch, and submitting translation api documentation etc...

* Community can be found here:: http://groups.google.com/group/lipsiadmin
* Api documentation can be found here:: http://api.lipsiasoft.com
11 changes: 9 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ desc 'Generate documentation for the lipsiadmin plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = 'Lipsiadmin'
rdoc.options << '--line-numbers' << '--inline-source'
rdoc.rdoc_files.include('README*')
rdoc.options << '--line-numbers' << '--inline-source' << '--accessor' << 'cattr_accessor=object'
rdoc.options << '--charset' << 'utf-8'
rdoc.template = 'resources/rdoc/horo'
rdoc.rdoc_files.include('README', 'CHANGELOG')
rdoc.rdoc_files.include('lib/**/*.rb')
end

Expand Down Expand Up @@ -69,6 +71,11 @@ task :gemspec do
end
end

desc "Publish the API documentation"
task :pdoc => [:rdoc] do
Rake::SshDirPublisher.new("root@server1.lipsiasoft.com", "/var/www/apps/lipsiadmin/rdoc", "doc").upload
end

desc "Publish the release files to RubyForge."
task :release => [ :package ] do
require 'rubyforge'
Expand Down
50 changes: 41 additions & 9 deletions lib/access_control/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,42 @@ module AccessControl
# This provide a simple login for backend and frontend.
# Use backend_login_required in backend and
# frontend_login_requirded in frontend.
#
# Examples:
#
# class FrontendController < ApplicationController
# before_filter :login_frontend_required, :except => [:login]
# end
#
module Authentication
protected

# Returns true if <tt>current_account</tt> is logged and active.
def logged_in?
current_account != :false && current_account.active?
end


# Returns the current_account, it's an instance of <tt>Account</tt> model
def current_account
@current_account ||= (login_from_session || :false)
end


# Ovverride the current_account, you must provide an instance of Account Model
#
# Examples:
#
# current_account = Account.last
#
def current_account=(new_account)
session[:account] = (new_account.nil? || new_account.is_a?(Symbol)) ? nil : new_account.id
@current_account = new_account
end

# Returns true if the <tt>current_account</tt> is allowed to see the requested
# controller/action.
#
# For configure this role please refer to: <tt>Lipsiadmin::AccessControl::Base</tt>
def allowed?

allowed = current_account.maps.collect(&:allowed)[0]
denied = current_account.maps.collect(&:denied)[0]

Expand All @@ -36,36 +55,49 @@ def allowed?
return allow && !deny
end

# Returns a helper to pass in a <tt>before_filter</tt> for check if
# an account are: <tt>logged_in?</tt> and <tt>allowed?</tt>
#
# By default this method is used in BackendController so is not necessary
def backend_login_required
logged_in? && allowed? || access_denied(:backend)
end


# Returns a helper to pass in a <tt>before_filter</tt> for check if
# an account are: <tt>logged_in?</tt> and <tt>allowed?</tt>
#
# Examples:
#
# before_filter :login_frontend_required, :except => [:login]
#
def fronted_login_required
logged_in? && allowed? || access_denied(:backend)
end

def access_denied(where)
def access_denied(where)#:nodoc:
respond_to do |format|
format.html { redirect_to :controller => "#{where}/sessions", :action => :new }
format.js { render(:update) { |page| page.alert "You don't allowed to access to this javascript" } }
end
false
end

def store_location
def store_location#:nodoc:
session[:return_to] = request.request_uri
end


# Redirect the account to the page that requested an authentication or
# if the account is not allowed/logged return it to a default page
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end

def self.included(base)
def self.included(base)#:nodoc:
base.send :helper_method, :current_account, :logged_in?
end

def login_from_session
def login_from_session#:nodoc:
self.current_account = Account.find_by_id(session[:account]) if session[:account]
end
end # Module Authentication
Expand Down
12 changes: 7 additions & 5 deletions lib/access_control/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,22 @@ def project_module(name, controller=nil, &block)
@project_modules << ProjectModule.new(name, controller, &block)
end

# Globally but for current role allow an action
# Globally allow an action of a controller for the current role
def allow_action(path)
@allowed << recognize_path(path)
end

# Globally but for current role deny an action
# Globally deny an action of a controllerfor the current role
def deny_action(path)
@denied << recognize_path(path)
end

# Globally but for current role allow an action
# Globally allow all actions from a controller for the current role
def allow_all_actions(path)
@allowed << { :controller => recognize_path(path)[:controller] }
end

# Globally but for current role deny an action
# Globally denty all actions from a controller for the current role
def deny_all_actions(path)
@denied << { :controller => recognize_path(path)[:controller] }
end
Expand Down Expand Up @@ -144,6 +144,7 @@ def initialize(name, path=nil, options={}, &block)#:nodoc:
yield self
end

# Build a new menu and automaitcally add the action on the allowed actions.
def menu(name, path=nil, options={}, &block)
@menus << Menu.new(name, path, options, &block)
end
Expand Down Expand Up @@ -220,6 +221,7 @@ def config
end
end

class AccessControlError < StandardError; end;
class AccessControlError < StandardError#:nodoc:
end
end
end
8 changes: 4 additions & 4 deletions lib/controller/lipsiadmin_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module Lipsiadmin#:nodoc:
module Controller#:nodoc:
# Base Backend Controller that defined:
# Base Backend Controller that define:
#
# layout false
# before_filter :backend_login_required
# helper Lipsiadmin::View::Helpers::BackendHelper
# layout false
# before_filter :backend_login_required
# helper Lipsiadmin::View::Helpers::BackendHelper
#
class Base < ActionController::Base
def self.inherited(subclass)#:nodoc:
Expand Down
18 changes: 16 additions & 2 deletions lib/controller/pdf_builder.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
module Lipsiadmin
module Controller
# This module convert a string/controller to
# This module convert a string/controller to a pdf through Pd4ml java library (included in this plugin)
#
# For generate a pdf you can simply do
#
# script/generate pdf invoice
#
# then edit your template /app/views/pdf/invoice.html.haml
#
# Then in any of your controllers add some like this:
#
# def generate_pdf_invoice
# render_pdf :invoice, 'invoice_file.pdf'
# end
#
module PdfBuilder
include Lipsiadmin::Utils::HtmlEntities

Expand Down Expand Up @@ -34,7 +47,8 @@ def render_pdf(template, filename, landescape = false)
end

# Errors For PDF
class PdfError < StandardError; end
class PdfError < StandardError#:nodoc:
end
end
end
end
9 changes: 6 additions & 3 deletions lib/controller/rescue.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
module Lipsiadmin
module Controller
# This module are raised when an exception fire up in controllers.
# Now you can personalize exception and simplify the layout using templates
# in app/views/exception
#
# Now you can personalize exception and simplify the layout using templates in:
#
# app/views/exception
#
# when an exception is raised it try to send an email, and for send an email
# you need to configure in enviroment or in an initializer some like this:
#
Expand All @@ -14,7 +17,7 @@ module Controller
#
module Rescue

def self.included(base)
def self.included(base)#:nodoc:
base.class_eval do
alias_method_chain :rescue_action_in_public, :notifier
end
Expand Down
1 change: 1 addition & 0 deletions lib/controller/responds_to_parent.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Lipsiadmin
module Controller
# Executes the response body as JavaScript in the context of the parent window.
#
# Use this method of you are posting a form to a hidden IFRAME or if you would like
# to use IFRAME base RPC.
module RespondsToParent
Expand Down
Loading

0 comments on commit 56ef3d8

Please sign in to comment.