pixelearth 3.2.2 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. data/app/assets/images/bgs/tan_textured.png +0 -0
  2. data/app/assets/images/icons/aa.gif +0 -0
  3. data/app/assets/images/icons/accept.png +0 -0
  4. data/app/assets/images/icons/arrow.png +0 -0
  5. data/app/assets/images/icons/back.png +0 -0
  6. data/app/assets/images/icons/block.png +0 -0
  7. data/app/assets/images/icons/coupon.png +0 -0
  8. data/app/assets/images/icons/destroy.png +0 -0
  9. data/app/assets/images/icons/dialog.png +0 -0
  10. data/app/assets/images/icons/download.png +0 -0
  11. data/app/assets/images/icons/edit.png +0 -0
  12. data/app/assets/images/icons/help.png +0 -0
  13. data/app/assets/images/icons/info.png +0 -0
  14. data/app/assets/images/icons/list_all.png +0 -0
  15. data/app/assets/images/icons/loading.gif +0 -0
  16. data/app/assets/images/icons/mail_send.png +0 -0
  17. data/app/assets/images/icons/new.png +0 -0
  18. data/app/assets/images/icons/next.png +0 -0
  19. data/app/assets/images/icons/no_avatar.jpg +0 -0
  20. data/app/assets/images/icons/process.png +0 -0
  21. data/app/assets/images/icons/show.png +0 -0
  22. data/app/assets/images/icons/spinning_wheel.gif +0 -0
  23. data/app/assets/images/icons/user.png +0 -0
  24. data/app/assets/images/icons/users.png +0 -0
  25. data/app/assets/images/icons/warning.png +0 -0
  26. data/app/assets/images/icons/wrench.png +0 -0
  27. data/app/assets/javascripts/application.js +9 -0
  28. data/app/assets/stylesheets/admin_layout.css.scss.erb +91 -0
  29. data/app/assets/stylesheets/defaults.css.scss.erb +26 -0
  30. data/app/assets/stylesheets/manifest_admin.css +11 -0
  31. data/app/assets/stylesheets/manifest_common.css +15 -0
  32. data/app/assets/stylesheets/pagination_will_paginate.scss.erb +68 -0
  33. data/app/assets/stylesheets/portable.css.scss.erb +151 -0
  34. data/app/assets/stylesheets/reset.css.scss.erb +50 -0
  35. data/app/assets/stylesheets/scaffolds.css.scss +58 -0
  36. data/app/assets/stylesheets/simple_form.scss +76 -0
  37. data/app/assets/stylesheets/validation_errors.scss +35 -0
  38. data/app/controllers/pixelearth_base/application_controller.rb +5 -0
  39. data/app/helpers/admin_panel_helpers.rb +13 -0
  40. data/app/helpers/application_controller_instance_methods_and_helpers.rb +8 -0
  41. data/app/helpers/controller_helpers.rb +128 -0
  42. data/app/helpers/layout_helpers.rb +5 -0
  43. data/app/helpers/pixelearth_base/application_helper.rb +6 -0
  44. data/app/helpers/view_helpers.rb +66 -0
  45. data/app/views/layouts/admin.html.haml +76 -0
  46. data/app/views/layouts/application.html.haml +61 -0
  47. data/app/views/pixelearth_base/_pagination.html.haml +8 -0
  48. data/app/views/pixelearth_base/admin/_admin_buttons.html.haml +20 -0
  49. data/app/views/pixelearth_base/admin/_form_errors.html.haml +8 -0
  50. data/app/views/pixelearth_base/admin/_show_edit_destroy.html.haml +6 -0
  51. data/config/initializers/active_record.rb +23 -0
  52. data/config/initializers/application_controller_additions.rb +31 -0
  53. data/config/initializers/date_formats.rb +5 -0
  54. data/config/initializers/rails_core_mods.rb +0 -0
  55. data/config/initializers/ruby_core_mods.rb +30 -0
  56. data/config/initializers/string.rb +22 -0
  57. data/config/routes.rb +0 -0
  58. data/lib/generators/project_files/templates/images/icons/aa.gif +0 -0
  59. data/lib/pixelearth.rb +4 -9
  60. data/lib/pixelearth/version.rb +1 -1
  61. data/lib/required/string.rb +3 -0
  62. metadata +61 -3
@@ -0,0 +1,58 @@
1
+ /*
2
+ body {
3
+ background-color: #fff;
4
+ color: #333;
5
+ font-family: verdana, arial, helvetica, sans-serif;
6
+ font-size: 13px;
7
+ line-height: 18px; }
8
+
9
+ p, ol, ul, td {
10
+ font-family: verdana, arial, helvetica, sans-serif;
11
+ font-size: 13px;
12
+ line-height: 18px; }
13
+
14
+ pre {
15
+ background-color: #eee;
16
+ padding: 10px;
17
+ font-size: 11px; }
18
+
19
+ a {
20
+ color: #000;
21
+ &:visited {
22
+ color: #666; }
23
+ &:hover {
24
+ color: #fff;
25
+ background-color: #000; } }
26
+
27
+ div {
28
+ &.field, &.actions {
29
+ margin-bottom: 10px; } }
30
+
31
+ #notice {
32
+ color: green; }
33
+
34
+ .field_with_errors {
35
+ padding: 2px;
36
+ background-color: red;
37
+ display: table; }
38
+
39
+ #error_explanation {
40
+ width: 450px;
41
+ border: 2px solid red;
42
+ padding: 7px;
43
+ padding-bottom: 0;
44
+ margin-bottom: 20px;
45
+ background-color: #f0f0f0;
46
+ h2 {
47
+ text-align: left;
48
+ font-weight: bold;
49
+ padding: 5px 5px 5px 15px;
50
+ font-size: 12px;
51
+ margin: -7px;
52
+ margin-bottom: 0px;
53
+ background-color: #c00;
54
+ color: #fff; }
55
+ ul li {
56
+ font-size: 12px;
57
+ list-style: square; } }
58
+ */
@@ -0,0 +1,76 @@
1
+ $left_col_w: 155px;
2
+ $dark_red: #CC0000;
3
+
4
+ .simple_form {
5
+ .input {
6
+ margin-bottom:10px;
7
+
8
+
9
+ label {
10
+ display:inline-block;
11
+ width:$left_col_w - 15;
12
+ margin-right:5px;
13
+ background-color:#f3f3f3;
14
+ padding:5px;
15
+ font-size:95%;
16
+ }
17
+ label.boolean {
18
+ display: block;
19
+ height: 20px;
20
+ }
21
+ /* lots of inconsistencies in browsers styling this element */
22
+ input.boolean {
23
+ display: block;
24
+ height: 20px;
25
+ margin-left: 155px;
26
+ margin-bottom:-25px;
27
+ width:45px;
28
+ }
29
+ label.collection_check_boxes {
30
+ display:inline;
31
+ background-color:transparent;
32
+ }
33
+ input {
34
+ width: 275px;
35
+ }
36
+ textarea {
37
+ height:200px;
38
+ vertical-align:top;
39
+ width: 275px;
40
+ padding:2px;
41
+ }
42
+ textarea.short {
43
+ height:100px;
44
+ }
45
+ .hint {
46
+ display:block;
47
+ margin-left: $left_col_w;
48
+ font-size:85%;
49
+ color:gray;
50
+ font-style: italic;
51
+ }
52
+ .error {
53
+ color:$dark_red;
54
+ display:block;
55
+ margin-left: $left_col_w;
56
+ }
57
+ abbr {
58
+ border-bottom:0;
59
+ color:orange;
60
+ }
61
+
62
+ }
63
+ .actions {
64
+ margin:10px 0;
65
+ }
66
+ .input.field_with_errors { /* overwrites standard rails form validation css */
67
+ display:block;
68
+ background-color:transparent;
69
+ }
70
+
71
+ }
72
+
73
+ .form_section {
74
+ padding:15px;
75
+ background-color:#f3f3f3;
76
+ }
@@ -0,0 +1,35 @@
1
+ .field_with_errors {
2
+ padding: 2px;
3
+ background-color: #FFEBEB;
4
+ display:inline;
5
+ label {
6
+ color: #CC0000;
7
+ font-weight:800;
8
+ }
9
+ }
10
+
11
+ #error_explanation {
12
+ width: 450px;
13
+ border: 0px solid red;
14
+ padding: 7px;
15
+ padding-bottom: 2px;
16
+ margin-bottom: 20px;
17
+ background-color: #FFEBEB;
18
+ }
19
+
20
+ #error_explanation h2 {
21
+ text-align: left;
22
+ font-weight: bold;
23
+ padding: 5px 5px 5px 15px;
24
+ font-size: 12px;
25
+ margin: -7px;
26
+ margin-bottom: 0px;
27
+ background-color: #c00;
28
+ color: #FFEBEB;
29
+ }
30
+
31
+ #error_explanation ul li {
32
+ font-size: 12px;
33
+ list-style: square;
34
+ }
35
+
@@ -0,0 +1,5 @@
1
+ module PixelearthBase
2
+ class ApplicationController < ActionController::Base
3
+ #see initializer
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ module AdminPanelHelpers
2
+ def model_info
3
+ app_models.collect do |m|
4
+ link_txt = m.to_s.pluralize.underscore.humanize
5
+ link_path = m.to_s.underscore.pluralize + "_path"
6
+
7
+ if respond_to? link_path
8
+ [ link_txt, link_path ]
9
+ end
10
+ end.compact
11
+ end
12
+ end
13
+
@@ -0,0 +1,8 @@
1
+ module ApplicationControllerInstanceMethodsAndHelpers
2
+ # this module is meant to be included in ApplicationController
3
+ # the menthods are meant to be useful to controller and as helper_methods
4
+ # meant to be relatively reusable from app to app
5
+
6
+ include ControllerHelpers
7
+ end
8
+
@@ -0,0 +1,128 @@
1
+ module ControllerHelpers
2
+ # ----------- CONTROLLER --------------
3
+ #gets @resource or @resource for all actions in controller
4
+ #before filter is set per controller, thus overrideable.
5
+ def default_view_title #sets h1 and <title> defaults to something sensible, in the absense of explicit setting
6
+ case params[:action]
7
+ when 'new'
8
+ title_h1 "New #{controller_title}"
9
+ when 'create'
10
+ title_h1 "New #{controller_title} (with errors)"
11
+ when 'show'
12
+ title_h1 "#{controller_title}: #{controller_resource_name}"
13
+ when 'edit'
14
+ title_h1 "Editing #{controller_title}: #{controller_resource_name}"
15
+ when 'update'
16
+ title_h1 "Editing #{controller_title}: #{controller_resource_name} (with errors)"
17
+ when 'index'
18
+ title_h1 "Listing #{params[:controller].titleize}"
19
+ else
20
+ "#{params[:controller].titleize}: #{params[:action].titleize}"
21
+ end
22
+ end
23
+ def get_resource
24
+ a = params[:action].to_sym
25
+ c = params[:controller]
26
+ klass = c.classify.constantize
27
+ if [:show, :edit, :update, :destroy].include? a
28
+
29
+ instance_variable_set "@#{controller_resource_var}", klass.find(params[:id])
30
+
31
+ elsif a == :new
32
+
33
+ instance_variable_set "@#{controller_resource_var}", klass.new
34
+
35
+ elsif a == :create
36
+
37
+ instance_variable_set "@#{controller_resource_var}", klass.new(params[c.singularize])
38
+
39
+ elsif a == :index
40
+
41
+ instance_variable_set "@#{controller_resource_var}", klass.all
42
+
43
+ end
44
+
45
+ end
46
+ def controller_title
47
+ controller_resource_var.titleize
48
+ end
49
+ def controller_resource_var
50
+ if params[:action] == 'index'
51
+ params[:controller]
52
+ else
53
+ params[:controller].singularize
54
+ end
55
+ end
56
+ def controller_resource
57
+ begin
58
+ instance_variable_get "@#{controller_resource_var}"
59
+ rescue
60
+ 'error'
61
+ end
62
+ end
63
+ def controller_resource_name
64
+ if controller_resource
65
+ if controller_resource.respond_to? :name
66
+ controller_resource.titleize
67
+ else
68
+ controller_resource.id
69
+ end
70
+ end
71
+ end
72
+ # ----------- LAYOUT --------------
73
+ def display_flash (type = nil)
74
+
75
+ if type.nil? #show all flash keys
76
+ html = flash.collect { |type, val| display_flash(type) }.join("\n")
77
+ else
78
+ return flash[type].blank? ? "" : "<p class='flash flash_#{type}'>#{flash[type]}</p> \n"
79
+ end
80
+
81
+ html.html_safe
82
+ end
83
+ def title (st) #allow templates to set page title
84
+ @layout[:title] = strip_tags st
85
+ end
86
+ def h1 (st) #allow templates to set page h1
87
+ @layout[:h1] = st
88
+ end
89
+ def title_h1 (st) #allow templates to set page title and h1 at same time
90
+ h1(st)
91
+ title(st)
92
+ end
93
+ def h1_emph(st) #uniform way to make part of the h1 stand out
94
+ "<em>#{st}</em>"
95
+ end
96
+ def h1_name(st) #uniform way of displaying model names in h1
97
+ h1_emph "#{st.titleize}"
98
+ end
99
+ def add_css(s)
100
+ if !@layout[:css].include? s
101
+ @layout[:css] << s
102
+ end
103
+ end
104
+ def add_js(js)
105
+ if !@layout[:js].include? js
106
+ @layout[:js] << js
107
+ end
108
+ end
109
+ def layout_chooser #put one of these in the controller to override on a per controller basis
110
+ (['index', 'new', 'create', 'update', 'edit', 'destroy'].include? params[:action]) ? 'admin' : 'application'
111
+ end
112
+
113
+ # ----------- UTILS --------------
114
+ def strip_tags (str)
115
+ str.gsub(/<\/?[^>]*>/, "")
116
+ end
117
+ def app_controllers
118
+ Dir['app/controllers/*.rb'].map {|f| File.basename(f, '.*').camelize.constantize}
119
+ end
120
+ def app_models
121
+ Dir['app/models/*.rb'].map {|f| File.basename(f, '.*').camelize.constantize }
122
+ end
123
+
124
+
125
+
126
+
127
+
128
+ end
@@ -0,0 +1,5 @@
1
+ #include in ApplicationController as helper methods
2
+ #this file is meant to be transferable to other projects
3
+ module LayoutHelpers
4
+
5
+ end
@@ -0,0 +1,6 @@
1
+ module PixelearthBase
2
+ module ApplicationHelper
3
+ include ViewHelpers
4
+ include AdminPanelHelpers
5
+ end
6
+ end
@@ -0,0 +1,66 @@
1
+ #these helper are meant to not be needed as controller methods. Use ControllerHelpers instead
2
+ # the render :partial in 3.1 doesn't work the same when coming from a helper module as when defined with helper_method.
3
+ module ViewHelpers
4
+ def on_if_current(path)
5
+ if path == request.fullpath
6
+ 'on'
7
+ end
8
+ end
9
+ def on_if_controller(c)
10
+ if params[:controller] == c.to_s
11
+ 'on'
12
+ end
13
+ end
14
+ def tr(d)
15
+ # Quick array to table row.
16
+ # Takes an array and creates a table row (tr) with each element of the array
17
+ # occupying one column (td).
18
+ o = "<tr>\n"
19
+ d.each do |x|
20
+ o << "\t<td>#{x}</td>\n"
21
+ end
22
+ o << "</tr>\n"
23
+ o
24
+ end
25
+ def titled_link_to(resource)
26
+ link_to(resource.name.titleize, send("#{resource.class.to_s.underscore}_path", resource), :title => "View Full #{resource.class.to_s.titleize} Details for #{h resource.name.titleize}")
27
+ end
28
+ def short_text(st, len=100)
29
+ raw truncate( strip_tags( raw(st)), :length=>len)
30
+ end
31
+ def row_toggle
32
+ cycle('a','b')
33
+ end
34
+ def date(date, format=:default)
35
+ #ref: http://snippets.dzone.com/posts/show/2255
36
+ formats = {
37
+ :default => "%b %d, %Y",
38
+ :numbers => "%m-%d-%y",
39
+ :date_time => "%b %d, %Y %I:%M %p",
40
+ :just_time => "%I:%M %p",
41
+ }
42
+ date.strftime(formats[format])
43
+ end
44
+ def clear
45
+ "<br style='clear:both'/>".html_safe
46
+ end
47
+
48
+
49
+ # ----------- SCAFFOLD --------------
50
+ def form_errors_helper
51
+ render :partial => 'pixelearth_base/admin/form_errors'
52
+ end
53
+ def admin_buttons
54
+ render :partial => 'pixelearth_base/admin/admin_buttons'
55
+ end
56
+ def show_edit_destroy(resource)
57
+ render(:partial => 'pixelearth_base/admin/show_edit_destroy', :locals => {:resource => resource})
58
+ end
59
+ def link_to_destroy
60
+ raw link_to('destroy', @resource, :confirm => 'Are you sure you want to remove this?', :method => :delete, :title => 'remove permanently')
61
+ end
62
+ def paginate(collection)
63
+ render :partial => 'pixelearth_base/pagination.html.haml', :locals => { :collection => collection }
64
+ end
65
+
66
+ end
@@ -0,0 +1,76 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %title
5
+ = @layout[:title] || default_view_title
6
+ %meta{:name => 'keywords' , :content => @layout[:keywords]}
7
+ %meta{:name => 'description' , :content => @layout[:desc]}
8
+ %meta{:name => 'robots' , :content => @layout[:all]}
9
+ %meta{'http-equiv' => 'content-type' , :content => "text/html; charset=utf-8"}
10
+
11
+ = stylesheet_link_tag "application"
12
+ = javascript_include_tag "application"
13
+
14
+ = csrf_meta_tags
15
+
16
+ = stylesheet_link_tag *@layout[:css]
17
+ = stylesheet_link_tag *@layout[:admin][:css]
18
+ = javascript_include_tag *@layout[:admin][:js]
19
+
20
+ %style
21
+ = yield :styles
22
+
23
+
24
+ %body#body{:class=>"#{params[:controller]} #{params[:action]}"}
25
+
26
+ #head
27
+ %h1#layout
28
+ #{@layout[:admin][:title]}
29
+
30
+ - if @layout[:show_h1]
31
+
32
+ %h1#page
33
+ = raw @layout[:h1] || default_view_title
34
+
35
+ =clear
36
+
37
+ #container
38
+ = raw display_flash
39
+
40
+ #content
41
+ .section
42
+ = yield
43
+
44
+ #nav
45
+ .section
46
+ %h3 Manage Resources
47
+ %ul
48
+ %li= link_to 'Home', '/'
49
+ - model_info.each do |x|
50
+ %li= link_to x[0], send(x[1])
51
+
52
+ -#.section
53
+ -#%h3 Site Admin
54
+ -#%ul
55
+ -#- CONFIG['admin_menu'].each do |x|
56
+ -#%li
57
+ -#= link_to x.humanize, '' |
58
+ -## send("admin_#{x.sp_to_underscore}_path") |
59
+ = clear
60
+
61
+ #debug_box
62
+
63
+ =debug params
64
+ =debug session
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+ - if @layout[:uses_jquery_notify] #growl-like notifier
75
+ = render :partial => "shared/jquery_notify/templates"
76
+