classiccms 0.5.12 → 0.5.13

Sign up to get free protection for your applications and to get access to all the features.
data/classiccms.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_development_dependency "factory_girl"
25
25
  s.add_development_dependency "rack-test"
26
26
 
27
+
27
28
  #database
28
29
  s.add_runtime_dependency "mongoid", '3.0.4'
29
30
 
@@ -31,7 +32,6 @@ Gem::Specification.new do |s|
31
32
  s.add_runtime_dependency "sinatra"
32
33
  s.add_runtime_dependency "sinatra-support"
33
34
  s.add_runtime_dependency "sinatra-contrib"
34
- s.add_runtime_dependency "thin"
35
35
 
36
36
  #background processing
37
37
  s.add_runtime_dependency "celluloid", "~> 0.11.1"
@@ -2,10 +2,8 @@ require "mongoid"
2
2
  require 'haml'
3
3
  require 'sinatra/base'
4
4
  require 'sinatra/support'
5
- require "sinatra"
6
- require 'thin'
5
+ require 'sinatra'
7
6
  require 'tilt'
8
- require "tilt"
9
7
  require "haml"
10
8
  require "sass"
11
9
  require "slim"
@@ -1,3 +1,4 @@
1
+
1
2
  module Classiccms
2
3
  class AdminController < ApplicationController
3
4
  include Classiccms::Routing
@@ -17,6 +18,53 @@ module Classiccms
17
18
  redirect to "/#{params[:model]}}"
18
19
  end
19
20
  end
21
+ get '/all/:model' do
22
+ content_type 'text/plain'
23
+ csv = ''
24
+ fields = []
25
+ @model = params[:model].constantize
26
+ @model.fields.each do |key, info|
27
+ if !["_type", "_id", "created_at", "updated_at", "version", "deleted_at"].include? key
28
+ fields << key
29
+ csv += key + ','
30
+ end
31
+ end
32
+ csv += "\n"
33
+
34
+ @model.all.each do |i|
35
+ fields.each do |key|
36
+ csv += i[key].to_s + ','
37
+ end
38
+ csv += "\n"
39
+ end
40
+ return csv
41
+ end
42
+
43
+ get '/load' do
44
+
45
+ if Classiccms::CONFIG[:admin].include? params[:model]
46
+ @model = params[:model].constantize
47
+ fields = []
48
+ search = []
49
+ @model.fields.each do |key, info|
50
+ if !["_type", "_id", "created_at", "updated_at", "version", "deleted_at"].include? key
51
+ fields << key
52
+ search << {key => /^.*#{params[:sSearch]}.*/i}
53
+ end
54
+ end
55
+
56
+ @records = @model.any_of(search).order_by([fields[params[:iSortCol_0].to_i], params[:sSortDir_0]])[params[:iDisplayStart].to_i, params[:iDisplayStart].to_i + params[:iDisplayLength].to_i]
57
+ result = {"sEcho" => params['sEcho'], "iTotalRecords" => @model.all.count, "iTotalDisplayRecords" => @model.all.count, "aaData" => []}
58
+ result['aaData'] = @records.map do|i|
59
+ items = []
60
+ fields.each do |key|
61
+ items << i[key] == nil ? "" : i[key]
62
+ end
63
+ items << edit(i.id).to_a
64
+ end
65
+ return result.to_json
66
+ end
67
+ end
20
68
  get '/:model' do
21
69
  if Classiccms::CONFIG[:admin].include? params[:model]
22
70
  @model = params[:model].constantize
@@ -24,5 +72,6 @@ module Classiccms
24
72
  show 'index'
25
73
  end
26
74
  end
75
+
27
76
  end
28
77
  end
@@ -8,6 +8,7 @@ module Classiccms
8
8
  return item
9
9
  end
10
10
  end
11
+ return nil
11
12
  end
12
13
 
13
14
  #This method will get you the most awesome route through a tree! (OMG!)
@@ -1,5 +1,11 @@
1
1
  $(document).ready(function() {
2
2
  $('#example').dataTable( {
3
-
3
+ "bProcessing": true,
4
+ "bServerSide": true,
5
+ "sAjaxSource": "/admin/load",
6
+ "fnServerParams": function ( aoData ) {
7
+ model_name = $('input[name=model]').first().val();
8
+ aoData.push( { "name": "model", "value": model_name} );
9
+ }
4
10
  });
5
11
  });
@@ -1,3 +1,3 @@
1
1
  module Classiccms #:nodoc
2
- VERSION = "0.5.12"
2
+ VERSION = "0.5.13"
3
3
  end
@@ -29,7 +29,10 @@
29
29
  .fill
30
30
  .container
31
31
  - if @model != nil
32
- %a{:href => "/admin/destroy/#{@model}"} Destroy All!
32
+ %input{:type => 'hidden', :name => 'model', :value => @model}
33
+
34
+ %a{:href => "/admin/all/#{@model}"} Download CSV
35
+ %a{:style => 'float: right;', :href => "/admin/destroy/#{@model}"} Destroy All!
33
36
  %br
34
37
  %br
35
38
  #demo
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: classiccms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.12
4
+ version: 0.5.13
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-03 00:00:00.000000000 Z
12
+ date: 2012-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -155,22 +155,6 @@ dependencies:
155
155
  - - ! '>='
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
- - !ruby/object:Gem::Dependency
159
- name: thin
160
- requirement: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ! '>='
164
- - !ruby/object:Gem::Version
165
- version: '0'
166
- type: :runtime
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
- requirements:
171
- - - ! '>='
172
- - !ruby/object:Gem::Version
173
- version: '0'
174
158
  - !ruby/object:Gem::Dependency
175
159
  name: celluloid
176
160
  requirement: !ruby/object:Gem::Requirement