repres-dosser 1.7 → 1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +63 -4
- data/Rakefile +2 -2
- data/app/assets/config/repres-dosser_manifest.js +2 -0
- data/app/assets/javascripts/repres/dosser/application.js +1 -1
- data/app/assets/stylesheets/repres/dosser/application.css +3 -3
- data/app/controllers/repres/dosser/application_controller.rb +1 -0
- data/app/controllers/repres/dosser/concerns/resource_presentation.rb +1 -1
- data/app/jobs/repres/dosser/application_job.rb +2 -0
- data/app/mailers/repres/dosser/application_mailer.rb +4 -0
- data/app/models/repres/dosser/application_record.rb +3 -0
- data/app/views/layouts/repres/dosser/application.html.erb +2 -2
- data/lib/repres/dosser/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17689051bfd88e10055fbbd422d843489de7d2e3
|
4
|
+
data.tar.gz: b73a7a1b231ff41e878aea8dbc9b1c7a0f871c51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c33194a418ecf6d6d71673ff51b2dff498833e6403f279c4ff3fd24c4d32a044593ed0dc1b7fb06d17f860f57aa10da372f008c762f59588764986992af2cefc
|
7
|
+
data.tar.gz: ec373d379cc1f663e2cb6ca2aa7d5bd7226f830d6a22e5a8eb3566739c7661cbac730705eb82189b8a1db914dc8a0b6e0b1b6470e13c6241e03c3a6160a906ec
|
data/README.md
CHANGED
@@ -2,24 +2,37 @@
|
|
2
2
|
|
3
3
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT)
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/repres-dosser.svg)](https://badge.fury.io/rb/repres-dosser)
|
5
|
+
[![Dependency Status](https://gemnasium.com/badges/github.com/topbitdu/repres-dosser.svg)](https://gemnasium.com/github.com/topbitdu/repres-dosser)
|
5
6
|
|
6
7
|
Repres (REsource PRESentation) is a series of resource presentation engines. The Dosser (DOmain-Specific SEmantic Representation) resource presentation engine includes JSON and XML resource presentation templates.
|
7
8
|
Repres (资源表现)是一系列的资源表现引擎。Dosser (领域特定语意表现) 资源表现引擎包括JSON和XML表现模版。
|
8
9
|
|
10
|
+
|
11
|
+
|
9
12
|
## Why Use Repres Dosser
|
13
|
+
|
10
14
|
Dosser pre-defined some glossaries for RESTful Web API, which follows the Template Method design pattern.
|
11
15
|
Dosser 预定义了一些适用于 RESTful Web API 的词汇,并且采用了“模版方法”设计模式。
|
12
16
|
|
17
|
+
|
18
|
+
|
13
19
|
## Recent Update
|
20
|
+
|
14
21
|
Check out the [Road Map](ROADMAP.md) to find out what's the next.
|
15
22
|
Check out the [Change Log](CHANGELOG.md) to find out what's new.
|
16
23
|
|
24
|
+
|
25
|
+
|
17
26
|
## Usage in Gemfile
|
27
|
+
|
18
28
|
```ruby
|
19
29
|
gem 'repres-dosser'
|
20
30
|
```
|
21
31
|
|
32
|
+
|
33
|
+
|
22
34
|
## Include the Concern in Controllers & Respond the Calls
|
35
|
+
|
23
36
|
```ruby
|
24
37
|
include Repres::Dosser::Concerns::ResourcePresentation
|
25
38
|
|
@@ -41,7 +54,57 @@ The following responding methods are supported:
|
|
41
54
|
- 409 render_conflict
|
42
55
|
- 500 render_internal_server_error
|
43
56
|
|
57
|
+
The Resource Presentation supports JSONP automatically. Which means ``GET /resources/id.json`` returns a standard JSON:
|
58
|
+
```json
|
59
|
+
{
|
60
|
+
"success": true,
|
61
|
+
"code": "success",
|
62
|
+
"message": "成功",
|
63
|
+
"size": 1,
|
64
|
+
"errors": {},
|
65
|
+
"collection":
|
66
|
+
[
|
67
|
+
{
|
68
|
+
"name": "My Name",
|
69
|
+
"links": []
|
70
|
+
}
|
71
|
+
],
|
72
|
+
"meta":
|
73
|
+
{
|
74
|
+
"criteria": null,
|
75
|
+
"request_id": "54fc3aa3-d062-4bad-b544-a08c7df5ef0c",
|
76
|
+
"timestamp": 1479114866
|
77
|
+
}
|
78
|
+
}
|
79
|
+
```
|
80
|
+
If a callback parameter is given as ``GET /resources/id.json?callback=onResourceLoaded``, the following JSON is returned:
|
81
|
+
```json
|
82
|
+
onResourceLoaded(
|
83
|
+
{
|
84
|
+
"success": true,
|
85
|
+
"code": "success",
|
86
|
+
"message": "成功",
|
87
|
+
"size": 1,
|
88
|
+
"errors": {},
|
89
|
+
"collection":
|
90
|
+
[
|
91
|
+
{
|
92
|
+
"name": "My Name",
|
93
|
+
"links": []
|
94
|
+
}
|
95
|
+
],
|
96
|
+
"meta":
|
97
|
+
{
|
98
|
+
"criteria": null,
|
99
|
+
"request_id": "54fc3aa3-d062-4bad-b544-a08c7df5ef0c",
|
100
|
+
"timestamp": 1479114866
|
101
|
+
}
|
102
|
+
}
|
103
|
+
);
|
104
|
+
```
|
105
|
+
|
44
106
|
### Pagination
|
107
|
+
|
45
108
|
```ruby
|
46
109
|
include Repres::Dosser::Concerns::ResourcePresentation
|
47
110
|
|
@@ -68,8 +131,6 @@ onIndexResourceSuccess: function(data, textStatus, jqXHR)
|
|
68
131
|
|
69
132
|
## Generators
|
70
133
|
|
71
|
-
|
72
|
-
|
73
134
|
### Platform generator
|
74
135
|
|
75
136
|
```shell
|
@@ -89,8 +150,6 @@ app/controllers/administration/dosser/v2/presentation_controller.rb
|
|
89
150
|
app/controllers/administration/dosser/v2/portals_controller.rb
|
90
151
|
```
|
91
152
|
|
92
|
-
|
93
|
-
|
94
153
|
### Swagger generator
|
95
154
|
|
96
155
|
```shell
|
data/Rakefile
CHANGED
@@ -10,7 +10,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
10
|
rdoc.rdoc_dir = 'rdoc'
|
11
11
|
rdoc.title = 'Repres Dosser'
|
12
12
|
rdoc.options << '--line-numbers'
|
13
|
-
rdoc.rdoc_files.include('README.
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
@@ -20,5 +20,5 @@ load 'rails/tasks/statistics.rake'
|
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
|
23
|
+
require 'bundler/gem_tasks'
|
24
24
|
|
@@ -5,7 +5,7 @@
|
|
5
5
|
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
6
|
//
|
7
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
9
|
//
|
10
10
|
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
@@ -6,9 +6,9 @@
|
|
6
6
|
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
7
|
*
|
8
8
|
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any
|
10
|
-
*
|
11
|
-
* file per style scope.
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
12
|
*
|
13
13
|
*= require_self
|
14
14
|
*/
|
@@ -226,7 +226,7 @@ module Repres::Dosser::Concerns::ResourcePresentation
|
|
226
226
|
result[:meta] = { criteria: @criteria, request_id: request.uuid, timestamp: Time.now.to_i }
|
227
227
|
result[:meta][:pagination] = @pagination if @pagination.present?
|
228
228
|
respond_to do |format|
|
229
|
-
format.json do render status: status, json: result end
|
229
|
+
format.json do render status: status, json: result, callback: params[:callback] end
|
230
230
|
format.xml do render status: status, xml: result end
|
231
231
|
end
|
232
232
|
end
|
@@ -2,14 +2,14 @@
|
|
2
2
|
<html>
|
3
3
|
<head>
|
4
4
|
<title>Repres Dosser</title>
|
5
|
-
<%= stylesheet_link_tag
|
5
|
+
<%= stylesheet_link_tag "repres/dosser/application", media: "all" %>
|
6
6
|
<%= csrf_meta_tags %>
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
10
10
|
<%= yield %>
|
11
11
|
|
12
|
-
<%= javascript_include_tag 'dosser/application' %>
|
12
|
+
<%= javascript_include_tag 'repres/dosser/application' %>
|
13
13
|
|
14
14
|
</body>
|
15
15
|
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: repres-dosser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '1.
|
4
|
+
version: '1.8'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Topbit Du
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,11 +37,15 @@ files:
|
|
37
37
|
- MIT-LICENSE
|
38
38
|
- README.md
|
39
39
|
- Rakefile
|
40
|
+
- app/assets/config/repres-dosser_manifest.js
|
40
41
|
- app/assets/javascripts/repres/dosser/application.js
|
41
42
|
- app/assets/stylesheets/repres/dosser/application.css
|
42
43
|
- app/controllers/repres/dosser/application_controller.rb
|
43
44
|
- app/controllers/repres/dosser/concerns/resource_presentation.rb
|
44
45
|
- app/helpers/repres/dosser/application_helper.rb
|
46
|
+
- app/jobs/repres/dosser/application_job.rb
|
47
|
+
- app/mailers/repres/dosser/application_mailer.rb
|
48
|
+
- app/models/repres/dosser/application_record.rb
|
45
49
|
- app/views/layouts/repres/dosser/application.html.erb
|
46
50
|
- config/routes.rb
|
47
51
|
- lib/generators/repres/dosser/platform/USAGE
|