datatable_state 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 62f8861ff6bc31e2f80a6d757a8887bf867bb581
4
+ data.tar.gz: f7d30c335f1de063739d2052801034934841747e
5
+ SHA512:
6
+ metadata.gz: 6d52f9eac4859fde6e0681b70bc35ae073af7077d8daa5b25a160a6a5e9b5cbc5d6bce363d645df00e6b667211cbeb3cd30bfd5e33999208f6cc8e64cabd1542
7
+ data.tar.gz: 7f00cb0319fa1d0b9b0a10aaded4188eedaa5936354838fe838bd0b97bbf86d5f153858969a5b0ff91cbfd82f030aa079fe40320f6ddc67304a1d78e9463c3b6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,2 @@
1
+ rake datatable_state:install:migrations
2
+ rake db:migrate
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'DatatableState'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+
24
+
25
+
26
+ Bundler::GemHelper.install_tasks
27
+
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module DatatableState
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,41 @@
1
+ require_dependency "datatable_state/application_controller"
2
+
3
+ module DatatableState
4
+ class StoreController < ApplicationController
5
+ respond_to :json
6
+ before_filter :get_state
7
+
8
+ def save
9
+ if @store
10
+ @store.update_attributes(params[:datatable_state])
11
+ else
12
+ @store = DatatableState.new(params[:datatable_state])
13
+ @store.user = current_user
14
+ end
15
+
16
+ respond_to do |format|
17
+ if @store.save
18
+ format.json { render json: @store, status: :created }
19
+ else
20
+ format.json { render json: @store.errors, status: :unprocessable_entity }
21
+ end
22
+ end
23
+ end
24
+
25
+ def load
26
+ result = if @store
27
+ @store.state
28
+ else
29
+ {}.as_json
30
+ end
31
+ respond_with result
32
+ end
33
+
34
+ private
35
+
36
+ def get_state
37
+ @store = Store.find_by_user_id_and_path(current_user.id,
38
+ params[:datatable_state][:path])
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,4 @@
1
+ module DatatableState
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,8 @@
1
+ module DatatableState
2
+ class Store < ActiveRecord::Base
3
+ self.table_name = :datatable_states
4
+ belongs_to :user
5
+
6
+ attr_accessible :path, :state
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>DatatableState</title>
5
+ <%= stylesheet_link_tag "datatable_state/application", :media => "all" %>
6
+ <%= javascript_include_tag "datatable_state/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ DatatableState::Engine.routes.draw do
2
+ get 'store/load'
3
+ post 'store/save'
4
+ end
@@ -0,0 +1,12 @@
1
+ class CreateDatatableStates < ActiveRecord::Migration
2
+ def change
3
+ create_table :datatable_states do |t|
4
+ t.references :user, index: true
5
+ t.string :path, index: true
6
+ t.text :state
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :datatable_states, [:user_id, :path], unique: true
11
+ end
12
+ end
@@ -0,0 +1,4 @@
1
+ require "datatable_state/engine"
2
+
3
+ module DatatableState
4
+ end
@@ -0,0 +1,5 @@
1
+ module DatatableState
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace DatatableState
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module DatatableState
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :datatable_state do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,87 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: datatable_state
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - denispeplin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Saving page lengths, search values, etc.
42
+ email:
43
+ - denis.peplin@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - README.md
50
+ - Rakefile
51
+ - app/assets/javascripts/datatable_state/application.js
52
+ - app/assets/stylesheets/datatable_state/application.css
53
+ - app/controllers/datatable_state/application_controller.rb
54
+ - app/controllers/datatable_state/store_controller.rb
55
+ - app/helpers/datatable_state/application_helper.rb
56
+ - app/models/datatable_state/store.rb
57
+ - app/views/layouts/datatable_state/application.html.erb
58
+ - config/routes.rb
59
+ - db/migrate/20141029083020_create_datatable_states.rb
60
+ - lib/datatable_state.rb
61
+ - lib/datatable_state/engine.rb
62
+ - lib/datatable_state/version.rb
63
+ - lib/tasks/datatable_state_tasks.rake
64
+ homepage: https://github.com/denispeplin/datatable_state
65
+ licenses: []
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.4.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Saving DataTables state to database
87
+ test_files: []