winton-admin 1.0.1 → 1.0.2

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 (38) hide show
  1. data/README.markdown +2 -0
  2. data/init.rb +1 -4
  3. data/lib/admin.rb +14 -0
  4. data/lib/admin/actions.rb +34 -0
  5. data/lib/admin/helpers.rb +4 -0
  6. data/resources/images/bg/top.jpg +0 -0
  7. data/resources/images/bg/top2.png +0 -0
  8. data/resources/images/bg/top3.png +0 -0
  9. data/resources/images/system_status.png +0 -0
  10. data/resources/images/title.psd +0 -0
  11. data/resources/javascripts/base.js +0 -0
  12. data/resources/stylesheets/base.sass +55 -0
  13. data/resources/views/layout.haml +40 -0
  14. data/resources/widgets/images/arrow_down.png +0 -0
  15. data/resources/widgets/images/arrow_up.png +0 -0
  16. data/resources/widgets/images/blue.png +0 -0
  17. data/resources/widgets/images/dark_header.png +0 -0
  18. data/resources/widgets/images/grey.png +0 -0
  19. data/resources/widgets/images/grey_header.png +0 -0
  20. data/resources/widgets/images/light_blue.png +0 -0
  21. data/resources/widgets/images/orange.png +0 -0
  22. data/resources/widgets/javascripts/admin.js +20 -0
  23. data/resources/widgets/javascripts/init.js +1 -0
  24. data/resources/widgets/nav/images/indicator.gif +0 -0
  25. data/resources/widgets/nav/javascripts/admin_nav.js +48 -0
  26. data/resources/widgets/nav/javascripts/init.js +2 -0
  27. data/resources/widgets/nav/options.rb +1 -0
  28. data/resources/widgets/nav/partials/_init.haml +9 -0
  29. data/resources/widgets/nav/stylesheets/nav.sass +10 -0
  30. data/resources/widgets/stylesheets/box.sass +25 -0
  31. data/resources/widgets/widgets/dialog/images/title.png +0 -0
  32. data/resources/widgets/widgets/dialog/options.rb +3 -0
  33. data/resources/widgets/widgets/dialog/stylesheets/admin.sass +45 -0
  34. data/resources/widgets/widgets/form/javascripts/init.js +13 -0
  35. data/resources/widgets/widgets/table/javascripts/init.js +13 -0
  36. data/resources/widgets/widgets/table/stylesheets/table.sass +54 -0
  37. data/tasks/admin_tasks.rake +56 -0
  38. metadata +60 -5
data/README.markdown CHANGED
@@ -3,6 +3,8 @@ Admin
3
3
 
4
4
  A quick way to implement a nice looking Admin in Rails.
5
5
 
6
+ **This plugin and dependencies are very beta. Use at your own risk.**
7
+
6
8
 
7
9
  Requirements
8
10
  ------------
data/init.rb CHANGED
@@ -1,4 +1 @@
1
- require 'admin'
2
-
3
- ActionView::Base.send :include, Admin::Helpers
4
- ActionController::Base.send :include, Admin::Actions
1
+ require 'admin'
data/lib/admin.rb ADDED
@@ -0,0 +1,14 @@
1
+ Dir[File.expand_path('*/*.rb', File.dirname(__FILE__))].each do |f|
2
+ require [ File.dirname(f), File.basename(f, '.rb') ].join('/')
3
+ end
4
+
5
+ module Admin
6
+ class << self
7
+ def routes
8
+ ActionController::Routing::Routes.add_route '/admin/:action/:id', :controller => 'admin'
9
+ end
10
+ end
11
+ end
12
+
13
+ ActionView::Base.send :include, Admin::Helpers
14
+ ActionController::Base.send :include, Admin::Actions
@@ -0,0 +1,34 @@
1
+ module Admin
2
+ module Actions
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def acts_as_admin(*actions)
10
+ self.class_eval do
11
+ cattr_accessor :admin_sections
12
+ helper_method :admin_sections
13
+ self.admin_sections = actions.sort { |a, b| a.to_s <=> b.to_s }
14
+
15
+ actions.each do |action|
16
+ define_method action do
17
+ @title ||= [ 'Admin' ]
18
+ @title << action.to_s.capitalize.gsub('_', ' ')
19
+ render :layout => false
20
+ end
21
+ end
22
+ end
23
+ include Admin::Actions::InstanceMethods
24
+ end
25
+ end
26
+
27
+ module InstanceMethods
28
+ def index
29
+ @title ||= [ 'Admin' ]
30
+ render :layout => 'admin/system/layout'
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module Admin
2
+ module Helpers
3
+ end
4
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
File without changes
@@ -0,0 +1,55 @@
1
+ body
2
+ :font-family Helvetica, Arial, sans-serif
3
+ :margin 0px 0px 15px
4
+ :color #6F687A
5
+
6
+ a
7
+ :color #2F4E7F
8
+ :font-weight bold
9
+
10
+ .row
11
+ :overflow hidden
12
+ .parent
13
+ :float left
14
+ :display block
15
+
16
+ #top
17
+ :height 150px
18
+ :background-color #101D40
19
+ :background-image url('/images/admin/system/bg/top.jpg')
20
+ :background-repeat no-repeat
21
+ :background-position top center
22
+ .content
23
+ :width 970px
24
+ :margin 0px auto
25
+ :padding 112px 0px 0px
26
+
27
+ #top2
28
+ :height 35px
29
+ :border-top 1px solid #F5F6F9
30
+ :background #ACBCCF url('/images/admin/system/bg/top2.png')
31
+
32
+ #top3
33
+ :height 100px
34
+ :background #F5F6F9 url('/images/admin/system/bg/top3.png')
35
+ .content
36
+ :width 970px
37
+ :margin 0px auto
38
+ :padding-top 14px
39
+ .system_status1 .cell
40
+ :padding-top 15px
41
+ :color #26416E
42
+ :font-size 16px
43
+ :font-weight bold
44
+ .system_status2 .cell
45
+ :padding 11px 0px 0px 15px
46
+ :line-height 24px
47
+ :font-size 14px
48
+
49
+ #content
50
+ .content
51
+ :width 970px
52
+ :margin 0px auto
53
+ :padding-top 15px
54
+ .body1 .body_cell
55
+ :padding-left 15px
@@ -0,0 +1,40 @@
1
+ - require_widget :admin, :nav
2
+ - require_widget :admin, :widgets, :dialog
3
+ - require_widget :admin, :widgets, :indicator, :mouse
4
+ - require_widget :admin, :widgets, :form
5
+ - require_widget :admin, :widgets, :table
6
+
7
+ !!! Strict
8
+ %html
9
+ %head
10
+ %title= @title.join(' - ')
11
+ - javascripts 'admin/system/base', :layout => true
12
+ - stylesheets 'admin/system/base', :layout => true
13
+ = stylesheets
14
+ %body
15
+ - render_widget :admin
16
+ - render_widget :admin, :widgets, :dialog
17
+ - render_widget :admin, :widgets, :indicator, :mouse
18
+ #top
19
+ .content= image_tag 'admin/title.png'
20
+ #top2
21
+ #top3
22
+ .content
23
+ - tbl :row, :system_status, :px, 75, 115, 780 do
24
+ - tbl :cell, :system_status do
25
+ = image_tag 'admin/system/system_status.png'
26
+ - tbl :cell, :system_status do
27
+ System status
28
+ - tbl :cell, :system_status do
29
+ You’ll be happy to know that your
30
+ %b 3 mongrels (2 production, 1 staging)
31
+ are running at
32
+ %b 3% of capacity.
33
+ #content
34
+ .content
35
+ - tbl :row, :body, :px, 190, 780 do
36
+ - tbl :cell, :body do
37
+ = render_widget :admin, :nav
38
+ - tbl :cell, :body do
39
+ = yield
40
+ = javascripts
Binary file
Binary file
Binary file
@@ -0,0 +1,20 @@
1
+ var Admin = new Class({
2
+ initialize: function() {
3
+ var body = $$('.body1 .cell')[0];
4
+
5
+ this.addContent = function(el) {
6
+ body.getChildren().hide();
7
+ body.setStyle('opacity', 0);
8
+ if (el)
9
+ el.inject(body, 'top');
10
+ body.fade('in');
11
+ };
12
+
13
+ this.back = function(no_show) {
14
+ if (body.getFirst())
15
+ body.getFirst().destroy();
16
+ if (body.getFirst() && !no_show)
17
+ body.getFirst().fadeIn();
18
+ };
19
+ }
20
+ });
@@ -0,0 +1 @@
1
+ Global.Admin = new Admin();
@@ -0,0 +1,48 @@
1
+ var AdminNav = new Class({
2
+ initialize: function() {
3
+ var over = 'light_blue';
4
+ var out = 'grey';
5
+ var click = 'orange';
6
+
7
+ var els = $$('.nav .grey');
8
+ var me = this;
9
+
10
+ this.reloadTable = function() {
11
+ var indicator = this.selected.getElement('.indicator');
12
+ indicator.fade('in');
13
+ var request = new Request.HTML({
14
+ evalScripts: false,
15
+ onSuccess: function(tree, elements, html, js) {
16
+ Global.Admin.addContent(elements[0]);
17
+ indicator.fade('out');
18
+ eval(js);
19
+ }
20
+ }).get('/admin/' + this.selected.id);
21
+ };
22
+
23
+ els.addEvent('mouseenter', function() {
24
+ if (this.hasClass(click)) return;
25
+ this.removeClass(out);
26
+ this.addClass(over);
27
+ });
28
+
29
+ els.addEvent('mouseleave', function() {
30
+ if (this.hasClass(click)) return;
31
+ this.removeClass(over);
32
+ this.addClass(out);
33
+ });
34
+
35
+ els.addEvent('click', function() {
36
+ els.each(function(item) { if (item != this) item.removeClass(click); }, this);
37
+ els.addClass(out);
38
+ this.removeClass(out);
39
+ this.toggleClass(over);
40
+ this.toggleClass(click);
41
+ Global.Admin.back();
42
+ if (this.hasClass(click)) {
43
+ me.selected = this;
44
+ me.reloadTable();
45
+ }
46
+ });
47
+ }
48
+ });
@@ -0,0 +1,2 @@
1
+ var Global = Global || {};
2
+ Global.AdminNav = new AdminNav();
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,9 @@
1
+ .box
2
+ .nav
3
+ .blue
4
+ Main menu
5
+ - admin_sections.each do |section|
6
+ .grey{ :id => section }
7
+ .indicator
8
+ = image_tag 'widgets/admin/nav/indicator.gif'
9
+ = section.to_s.capitalize.gsub '_', ' '
@@ -0,0 +1,10 @@
1
+ .box
2
+ .nav
3
+ .blue
4
+ :font-size 13px
5
+ .grey, .light_blue, .orange
6
+ :cursor pointer
7
+ .grey
8
+ :background #F5F6F9 url('/images/widgets/admin/grey.png')
9
+ .indicator
10
+ :opacity 0
@@ -0,0 +1,25 @@
1
+ .box
2
+ .blue, .light_blue, .grey, .orange, .table_rows_cell
3
+ :font-size 12px
4
+ :padding-left 10px
5
+ .blue, .light_blue, .grey, .orange
6
+ :height 25px
7
+ :line-height 25px
8
+ .blue, .light_blue, .orange
9
+ :font-weight bold
10
+ .blue
11
+ :background #F5F6F9 url('/images/widgets/admin/blue.png')
12
+ :color #fff
13
+ .light_blue
14
+ :background #F5F6F9 url('/images/widgets/admin/light_blue.png')
15
+ :color #fff
16
+ .grey
17
+ :border-left 1px solid #CBCFD6
18
+ :border-right 1px solid #CBCFD6
19
+ .orange
20
+ :background #F5F6F9 url('/images/widgets/admin/orange.png')
21
+ :color #fff
22
+ .indicator
23
+ :float right
24
+ :padding 4px 5px 0px 0px
25
+ :line-height 0px
@@ -0,0 +1,3 @@
1
+ {
2
+ :width => 500
3
+ }
@@ -0,0 +1,45 @@
1
+ .dialog
2
+ :font-size 12px
3
+ .close
4
+ :padding 4px 5px 2px
5
+ :margin-left -4px
6
+ :color #D78333
7
+ :font-weight bold
8
+ .content
9
+ :padding 0px 8px 5px
10
+ :min-height 11px
11
+ fieldset
12
+ :border 1px solid #ddd
13
+ legend
14
+ :font-weight bold
15
+ :font-size 14px
16
+ :padding-top 2px
17
+ :padding-left 21px
18
+ :background-image url('<%= widget_image_path :admin, :widgets, :dialog, "title.png" %>')
19
+ :background-repeat no-repeat
20
+ :background-position 0px 0px
21
+ :line-height 16px
22
+ .field.clear
23
+ :clear both
24
+ .field
25
+ :float left
26
+ :padding 4px 0px 8px 10px
27
+ :width 220px
28
+ input
29
+ :width 200px
30
+ textarea
31
+ :width 440px
32
+ :height 150px
33
+ .name, .formError
34
+ :line-height 22px
35
+ :font-weight bold
36
+ .formError
37
+ :float right
38
+ :color red
39
+ :font-size 10px
40
+ :height 14px
41
+ :padding-right 10px
42
+ .submit
43
+ :clear both
44
+ :float right
45
+ :padding-top 15px
@@ -0,0 +1,13 @@
1
+ Global['<%= id %>'].addEvents({
2
+ complete: function(el, js) {
3
+ if (el) Global.dialog.render({ element: el });
4
+ if (js) eval(js);
5
+ if (!el) {
6
+ Global.dialog.hide();
7
+ Global[Global.current_table].reload();
8
+ }
9
+ }
10
+ });
11
+ Global['<%= id %>'].form.addEvent('keyup', function(e) {
12
+ if (e.key == 'esc') Global.dialog.hide();
13
+ });
@@ -0,0 +1,13 @@
1
+ Global['<%= id %>'].addEvents({
2
+ newComplete: function(el, js) {
3
+ Global.dialog.render({ element: el });
4
+ Global.current_table = '<%= id %>';
5
+ eval(js);
6
+ },
7
+ editComplete: function(el, js) {
8
+ Global.dialog.render({ element: el });
9
+ Global.current_table = '<%= id %>';
10
+ eval(js);
11
+ },
12
+ deleteComplete: function(json) {}
13
+ });
@@ -0,0 +1,54 @@
1
+ .table_widget
2
+ :font-size 12px
3
+ .title
4
+ :padding-left 10px
5
+ :height 25px
6
+ :line-height 25px
7
+ :border-left 1px solid #CBCFD6
8
+ :border-right 1px solid #CBCFD6
9
+ :background #F5F6F9 url('<%= widget_image_path :admin, "grey_header.png" %>')
10
+ :font-weight bold
11
+ :font-size 13px
12
+ .links
13
+ :padding 0px 10px 0px 0px
14
+ .headers
15
+ :line-height 25px
16
+ :font-weight bold
17
+ :background #F5F6F9 url('<%= widget_image_path :admin, "light_blue.png" %>')
18
+ :color #fff
19
+ .arrow
20
+ :margin 10px 0px 0px 0px
21
+ .arrow.up
22
+ :background-image url('<%= widget_image_path :admin, "arrow_up.png" %>')
23
+ .arrow.down
24
+ :background-image url('<%= widget_image_path :admin, "arrow_down.png" %>')
25
+ .on
26
+ :background #F5F6F9 url('<%= widget_image_path :admin, "orange.png" %>')
27
+ :color #fff
28
+ .cell
29
+ :padding 0px 10px
30
+ .rows
31
+ :cursor pointer
32
+ .rows_cell
33
+ :padding 0px 10px
34
+ :height 24px
35
+ :line-height 24px
36
+ :border-left 1px solid #CCCFD7
37
+ :border-bottom 1px solid #CCCFD7
38
+ .rows_parent
39
+ .last
40
+ :border-right 1px solid #CCCFD7
41
+ .zebra .rows_cell
42
+ :background #EFF4FC
43
+ .zebra_highlight .rows_cell
44
+ :background #F9F6F0
45
+ .pagination
46
+ :float right
47
+
48
+ .table_widget_menu
49
+ :border 1px solid #CCCFD7
50
+ :background #E7E8ED
51
+ :padding 2px 5px
52
+ :margin 8px
53
+ :font-size 12px
54
+ :line-height 18px
@@ -0,0 +1,56 @@
1
+ desc 'Updates admin/system for all resources'
2
+ task :admin => [ 'admin:images', 'admin:javascripts', 'admin:stylesheets', 'admin:views', 'admin:widgets' ]
3
+
4
+ namespace :admin do
5
+ desc 'Updates images/admin/system'
6
+ task :images do
7
+ admin_resource :images, 'public/images'
8
+ end
9
+
10
+ desc 'Updates javascripts/admin/system'
11
+ task :javascripts do
12
+ admin_resource :javascripts, 'public/javascripts'
13
+ end
14
+
15
+ desc 'Updates stylesheets/admin/system'
16
+ task :stylesheets do
17
+ admin_resource :stylesheets, 'public/stylesheets/sass'
18
+ end
19
+
20
+ desc 'Updates views/admin/system'
21
+ task :views do
22
+ admin_resource :views, 'app/views'
23
+ end
24
+
25
+ desc 'Updates widgets/admin'
26
+ task :widgets do
27
+ admin_resource :widgets, 'app/widgets'
28
+ end
29
+
30
+ desc 'Updates plugin resources from app'
31
+ task :to_plugin do
32
+ admin_resource :images, 'public/images', true
33
+ admin_resource :javascripts, 'public/javascripts', true
34
+ admin_resource :stylesheets, 'public/stylesheets/sass', true
35
+ admin_resource :views, 'app/views', true
36
+ admin_resource :widgets, 'app/widgets', true
37
+ end
38
+
39
+ def admin_resource(type, location, reverse=false)
40
+ from = "#{File.dirname(__FILE__)}/../resources/#{type}"
41
+ to = location + (type == :widgets ? '/admin' : '/admin/system')
42
+ from, to = to, from if reverse
43
+ puts "=> Removing old #{type}..."
44
+ FileUtils.remove_dir to, true
45
+ FileUtils.mkdir_p to
46
+ puts "=> Copying #{type}..."
47
+ Dir["#{from}/*"].each do |f|
48
+ if File.directory? f
49
+ FileUtils.mkdir_p "#{to}/#{File.basename(f)}"
50
+ FileUtils.cp_r f, to
51
+ else
52
+ FileUtils.cp f, to
53
+ end
54
+ end
55
+ end
56
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: winton-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winton Welsh
@@ -23,12 +23,67 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - init.rb
26
- - lib/*
27
- - lib/**/*
26
+ - lib/admin
27
+ - lib/admin.rb
28
+ - lib/admin/helpers.rb
29
+ - lib/admin/actions.rb
28
30
  - MIT-LICENSE
29
31
  - README.markdown
30
- - resources/**/*
31
- - tasks/*
32
+ - resources/stylesheets
33
+ - resources/stylesheets/base.sass
34
+ - resources/views
35
+ - resources/views/layout.haml
36
+ - resources/javascripts
37
+ - resources/javascripts/base.js
38
+ - resources/images
39
+ - resources/images/bg
40
+ - resources/images/bg/top.jpg
41
+ - resources/images/bg/top2.png
42
+ - resources/images/bg/top3.png
43
+ - resources/images/system_status.png
44
+ - resources/images/title.psd
45
+ - resources/widgets
46
+ - resources/widgets/nav
47
+ - resources/widgets/nav/stylesheets
48
+ - resources/widgets/nav/stylesheets/nav.sass
49
+ - resources/widgets/nav/options.rb
50
+ - resources/widgets/nav/partials
51
+ - resources/widgets/nav/partials/_init.haml
52
+ - resources/widgets/nav/javascripts
53
+ - resources/widgets/nav/javascripts/admin_nav.js
54
+ - resources/widgets/nav/javascripts/init.js
55
+ - resources/widgets/nav/images
56
+ - resources/widgets/nav/images/indicator.gif
57
+ - resources/widgets/stylesheets
58
+ - resources/widgets/stylesheets/box.sass
59
+ - resources/widgets/javascripts
60
+ - resources/widgets/javascripts/admin.js
61
+ - resources/widgets/javascripts/init.js
62
+ - resources/widgets/images
63
+ - resources/widgets/images/light_blue.png
64
+ - resources/widgets/images/grey.png
65
+ - resources/widgets/images/arrow_down.png
66
+ - resources/widgets/images/blue.png
67
+ - resources/widgets/images/orange.png
68
+ - resources/widgets/images/arrow_up.png
69
+ - resources/widgets/images/grey_header.png
70
+ - resources/widgets/images/dark_header.png
71
+ - resources/widgets/widgets
72
+ - resources/widgets/widgets/form
73
+ - resources/widgets/widgets/form/javascripts
74
+ - resources/widgets/widgets/form/javascripts/init.js
75
+ - resources/widgets/widgets/table
76
+ - resources/widgets/widgets/table/stylesheets
77
+ - resources/widgets/widgets/table/stylesheets/table.sass
78
+ - resources/widgets/widgets/table/javascripts
79
+ - resources/widgets/widgets/table/javascripts/init.js
80
+ - resources/widgets/widgets/dialog
81
+ - resources/widgets/widgets/dialog/stylesheets
82
+ - resources/widgets/widgets/dialog/stylesheets/admin.sass
83
+ - resources/widgets/widgets/dialog/options.rb
84
+ - resources/widgets/widgets/dialog/images
85
+ - resources/widgets/widgets/dialog/images/title.png
86
+ - tasks/admin_tasks.rake
32
87
  has_rdoc: false
33
88
  homepage: http://github.com/winton/admin
34
89
  post_install_message: