Permalink
Browse files

Initial admin scaffold and post model

  • Loading branch information...
0 parents commit dc2a2a2fc5bf209b3d1a88e8882436133746d1c8 @nesquena nesquena committed Mar 17, 2010
Showing with 4,544 additions and 0 deletions.
  1. +2 −0 .bundle/config
  2. +6 −0 .components
  3. +7 −0 .gitignore
  4. +18 −0 Gemfile
  5. +32 −0 admin/app.rb
  6. +47 −0 admin/controllers/accounts.rb
  7. +7 −0 admin/controllers/base.rb
  8. +21 −0 admin/controllers/sessions.rb
  9. +40 −0 admin/views/accounts/_form.haml
  10. +15 −0 admin/views/accounts/edit.haml
  11. +31 −0 admin/views/accounts/index.haml
  12. +14 −0 admin/views/accounts/new.haml
  13. +11 −0 admin/views/base/_sidebar.haml
  14. +25 −0 admin/views/base/index.haml
  15. +31 −0 admin/views/layouts/application.haml
  16. +25 −0 admin/views/sessions/new.haml
  17. +43 −0 app/app.rb
  18. +43 −0 app/models/account.rb
  19. +3 −0 app/models/post.rb
  20. 0 app/views/layouts/.emptydirectory
  21. +2 −0 config.ru
  22. +21 −0 config/apps.rb
  23. +18 −0 config/boot.rb
  24. +48 −0 config/database.rb
  25. BIN db/development.db
  26. +16 −0 db/migrate/001_create_accounts.rb
  27. +12 −0 db/migrate/002_create_posts.rb
  28. +23 −0 db/schema.rb
  29. +28 −0 db/seeds.rb
  30. +12 −0 lib/sass.rb
  31. +94 −0 public/admin/stylesheets/base.css
  32. +364 −0 public/admin/stylesheets/themes/amro/style.css
  33. +290 −0 public/admin/stylesheets/themes/bec-green/style.css
  34. +301 −0 public/admin/stylesheets/themes/bec/style.css
  35. +287 −0 public/admin/stylesheets/themes/blue/style.css
  36. +373 −0 public/admin/stylesheets/themes/default/style.css
  37. +305 −0 public/admin/stylesheets/themes/djime-cerulean/style.css
  38. +279 −0 public/admin/stylesheets/themes/kathleene/style.css
  39. +345 −0 public/admin/stylesheets/themes/olive/style.css
  40. +269 −0 public/admin/stylesheets/themes/orange/style.css
  41. +302 −0 public/admin/stylesheets/themes/reidb-greenish/style.css
  42. +281 −0 public/admin/stylesheets/themes/ruby/style.css
  43. +391 −0 public/admin/stylesheets/themes/warehouse/style.css
  44. 0 public/favicon.ico
  45. +1 −0 public/javascripts/application.js
  46. +19 −0 public/javascripts/jquery.js
  47. +10 −0 test/models/account_test.rb
  48. +10 −0 test/models/post_test.rb
  49. +6 −0 test/test.rake
  50. +16 −0 test/test_config.rb
@@ -0,0 +1,2 @@
+---
+BUNDLE_WITHOUT: ""
@@ -0,0 +1,6 @@
+---
+:test: shoulda
+:orm: activerecord
+:mock: mocha
+:script: jquery
+:renderer: haml
@@ -0,0 +1,7 @@
+.DS_Store
+log/**/*
+tmp/**/*
+bin/*
+vendor/gems/*
+!vendor/gems/cache/
+.sass-cache/*
18 Gemfile
@@ -0,0 +1,18 @@
+source :gemcutter
+
+# Project requirements
+gem 'rack-flash'
+gem 'thin' # or mongrel
+
+# Component requirements
+gem 'haml'
+gem 'activerecord', :require => "active_record"
+gem 'sqlite3-ruby', :require => "sqlite3"
+
+# Test requirements
+gem 'mocha', :group => "test"
+gem 'shoulda', :group => "test"
+gem 'rack-test', :require => 'rack/test', :group => 'test'
+
+# Padrino
+gem 'padrino', "0.9.6"
@@ -0,0 +1,32 @@
+class Admin < Padrino::Application
+ configure do
+ ##
+ # Application-specific configuration options
+ #
+ # set :raise_errors, true # Show exceptions (default for development)
+ # set :public, "foo/bar" # Location for static assets (default root/public)
+ # set :sessions, false # Enabled by default
+ # set :reload, false # Reload application files (default in development)
+ # set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
+ # set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
+ # disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present)
+ # disable :padrino_mailer # Disables padrino mailer (enabled by default if present)
+ # disable :flash # Disables rack-flash (enabled by default)
+ # enable :authentication # Enable padrino-admin authentication (disabled by default)
+ # layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
+ #
+ enable :authentication
+ disable :store_location
+ set :login_page, "/admin/sessions/new"
+
+ access_control.roles_for :any do |role|
+ role.protect "/"
+ role.allow "/sessions"
+ end
+
+ access_control.roles_for :admin do |role, account|
+ role.project_module :accounts, "/accounts"
+ end
+
+ end
+end
@@ -0,0 +1,47 @@
+Admin.controllers :accounts do
+
+ get :index do
+ @accounts = Account.all
+ render 'accounts/index'
+ end
+
+ get :new do
+ @account = Account.new
+ render 'accounts/new'
+ end
+
+ post :create do
+ @account = Account.new(params[:account])
+ if @account.save
+ flash[:notice] = 'Account was successfully created.'
+ redirect url(:accounts, :edit, :id => @account.id)
+ else
+ render 'accounts/new'
+ end
+ end
+
+ get :edit, :with => :id do
+ @account = Account.find(params[:id])
+ render 'accounts/edit'
+ end
+
+ put :update, :with => :id do
+ @account = Account.find(params[:id])
+ if @account.update_attributes(params[:account])
+ flash[:notice] = 'Account was successfully updated.'
+ redirect url(:accounts, :edit, :id => @account.id)
+ else
+ render 'accounts/edit'
+ end
+ end
+
+ delete :destroy, :with => :id do
+ account = Account.find(params[:id])
+ if account.destroy
+ flash[:notice] = 'Account was successfully destroyed.'
+ else
+ flash[:error] = 'Impossible destroy Account!'
+ end
+ redirect url(:accounts, :index)
+ end
+end
@@ -0,0 +1,7 @@
+Admin.controllers :base do
+
+ get :index, :map => "(/)" do
+ render "base/index"
+ end
+
+end
@@ -0,0 +1,21 @@
+Admin.controllers :sessions do
+
+ get :new do
+ render "/sessions/new", nil, :layout => false
+ end
+
+ post :create do
+ if account = Account.authenticate(params[:email], params[:password])
+ set_current_account(account)
+ redirect url(:base, :index)
+ else
+ flash[:warning] = "Login or password wrong."
+ redirect url(:sessions, :new)
+ end
+ end
+
+ get :destroy do
+ set_current_account(nil)
+ redirect url(:sessions, :new)
+ end
+end
@@ -0,0 +1,40 @@
+.group
+ =f.label :name
+ =f.error_message_on :name
+ =f.text_field :name, :class => :text_field
+ %span.description Ex: a simple text
+
+.group
+ =f.label :surname
+ =f.error_message_on :surname
+ =f.text_field :surname, :class => :text_field
+ %span.description Ex: a simple text
+
+.group
+ =f.label :email
+ =f.error_message_on :email
+ =f.text_field :email, :class => :text_field
+ %span.description Ex: a simple text
+
+.group
+ =f.label :password
+ =f.error_message_on :password
+ =f.text_field :password, :class => :text_field
+ %span.description Ex: a simple text
+
+.group
+ =f.label :password_confirmation
+ =f.error_message_on :password_confirmation
+ =f.text_field :password_confirmation, :class => :text_field
+ %span.description Ex: a simple text
+
+.group
+ =f.label :role
+ =f.error_message_on :role
+ =f.select :role, :options => access_control.roles
+ %span.description Ex: a simple text
+
+
+.group.navform.wat-cf
+ =f.submit pat(:save), :class => :button
+ =f.submit pat(:cancel), :onclick => "window.location='#{url(:accounts, :index)}';return false", :class => :button
@@ -0,0 +1,15 @@
+.block
+ .secondary-navigation
+ %ul.wat-cf
+ %li.first=link_to pat(:list), url(:accounts, :index)
+ %li=link_to pat(:new), url(:accounts, :new)
+ %li.active=link_to pat(:edit), url(:accounts, :edit, :id => @account.id)
+ .content
+ %h2.title
+ =pat(:edit)
+ =mt(:account)
+ .inner
+ -form_for :account, url(:accounts, :update, :id => @account.id), :method => :put, :class => :form do |f|
+ =partial "accounts/form", :locals => { :f => f }
+
+-content_for :sidebar, partial("base/sidebar")
@@ -0,0 +1,31 @@
+.block
+ .secondary-navigation
+ %ul.wat-cf
+ %li.first.active=link_to pat(:list), url(:accounts, :index)
+ %li=link_to pat(:new), url(:accounts, :new)
+ .content
+ %h2.title
+ =pat(:all)
+ =mt(:account)
+ .inner
+ %table.table
+ %tr
+ %th.first=mat(:account, :id)
+ %th=mat(:account, :name)
+ %th=mat(:account, :surname)
+ %th=mat(:account, :email)
+ %th.last="&nbsp;"
+ -@accounts.each do |account|
+ %tr
+ %td.first=account.id
+ %td=account.name
+ %td=account.surname
+ %td=account.email
+ %td.last
+ =button_to pat(:edit), url(:accounts, :edit, :id => account.id), :method => :get, :class => :button_to
+ ="|"
+ =button_to pat(:delete), url(:accounts, :destroy, :id => account.id), :method => :delete, :class => :button_to
+ .actions-bar.wat-cf
+ .actions="&nbsp;"
+
+-content_for :sidebar, partial("base/sidebar")
@@ -0,0 +1,14 @@
+.block
+ .secondary-navigation
+ %ul.wat-cf
+ %li.first=link_to pat(:list), url(:accounts, :index)
+ %li.active=link_to pat(:new), url(:accounts, :new)
+ .content
+ %h2.title
+ =pat(:new)
+ =mt(:account)
+ .inner
+ -form_for :account, url(:accounts, :create), :class => :form do |f|
+ =partial "accounts/form", :locals => { :f => f }
+
+-content_for :sidebar, partial("base/sidebar")
@@ -0,0 +1,11 @@
+.block
+ %h3 Simple Block
+ .content
+ %p
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+.block
+ %h3 Links
+ %ul.navigation
+ %li=link_to "Link 1"
+ %li=link_to "Link 2"
@@ -0,0 +1,25 @@
+#block-text.block
+ .content
+ %h2.title Dashboard
+ .inner
+ %p.first
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+ %span.hightlight
+ Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+ %p
+ %span.small
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
+ %p
+ %span.gray
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore
+ %hr
+ %p
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
+ %span.hightlight
+ Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+-content_for :sidebar, partial("base/sidebar")
@@ -0,0 +1,31 @@
+!!! Strict
+%html{:lang => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
+ %head
+ %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
+ %title Padrino Admin
+ =stylesheet_link_tag :base, "themes/default/style"
+ %body
+ #container
+ #header
+ %h1=link_to "Padrino Admin", url(:base_index)
+ #user-navigation
+ %ul.wat-cf
+ %li=link_to pat(:profile), url(:accounts, :edit, :id => current_account.id)
+ %li=link_to pat(:logout), url(:sessions, :destroy), :method => :delete
+ #main-navigation
+ %ul.wat-cf
+ -project_modules.each do |project_module|
+ %li{:class => ("active" if request.path_info =~ /^#{project_module.path}/)}
+ =link_to project_module.human_name, project_module.path("/admin")
+ #wrapper.wat-cf
+ .flash=[:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
+ #main
+ =yield
+ #footer
+ .block
+ %p
+ Copyright ©
+ =Time.now.year
+ Your Site - Powered by
+ =link_to "Padrino v.#{Padrino.version}", "http://padrino.github.com", :target => :_blank
+ #sidebar=yield_content :sidebar
@@ -0,0 +1,25 @@
+!!! Strict
+%html{:lang => "en", :xmlns => "http://www.w3.org/1999/xhtml"}
+ %head
+ %meta{:content => "text/html; charset=utf-8", "http-equiv" => "Content-Type"}
+ %title Padrino Admin
+ =stylesheet_link_tag :base, :override, "themes/default/style"
+ %body
+ #container
+ #box
+ %h1 Padrino Admin
+ #block-login.block
+ %h2 Login Box
+ .content.login
+ .flash=[:error, :warning, :notice].map { |type| flash_tag(type, :class => "message #{type}") }.join
+ -form_tag(url(:sessions, :create), :class => 'form login') do
+ .group.wat-cf
+ .left
+ %label.label.right Login
+ .right=text_field_tag :email, :value => params[:email], :class => :text_field
+ .group.wat-cf
+ .left
+ %label.label.right Password
+ .right=password_field_tag :password, :value => params[:password], :class => :text_field
+ .group.navform.wat-cf
+ .right=submit_tag('Sign In', :class => :button)
Oops, something went wrong.

0 comments on commit dc2a2a2

Please sign in to comment.