kuppayam 0.1.8 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/helpers/render_api_helper.rb +46 -0
- data/app/views/kuppayam/api/docs/_example.html.erb +26 -0
- data/app/views/kuppayam/api/docs/_navigation.html.erb +19 -0
- data/app/views/kuppayam/api/docs/show.html.erb +94 -0
- data/app/views/layouts/kuppayam/docs.html.erb +2 -0
- data/config/locales/kuppayam/activerecord.ar.yml +8 -0
- data/config/locales/kuppayam/activerecord.en.yml +8 -0
- data/config/locales/kuppayam/api.ar.yml +6 -0
- data/config/locales/kuppayam/api.en.yml +6 -0
- data/config/locales/kuppayam/{general.yml → general.ar.yml} +0 -0
- data/config/locales/kuppayam/general.en.yml +30 -0
- data/lib/kuppayam/engine.rb +1 -1
- data/lib/kuppayam/version.rb +1 -1
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a97f179b81a0f520c6c8ad85e688729cf248df34
|
4
|
+
data.tar.gz: f8741775eae363062f3cd599badf3d14937ba2b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a83cad2bddf5e72cc8eb4ed8760a138f53f919e5b45f6d597085e90ca20c63c56a6349734aa3432b6a8c482609ef69e5b09996a017247c24eccdd12b96a0e91
|
7
|
+
data.tar.gz: 037c7fd5d131dc816ad241676c90bcb6b98c942c276b6bf41c8a646ae8c06abd70d41c2454643d4af2b6256c4394ee81656ee95af09155e578c4298be8d5cb79
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module RenderApiHelper
|
2
|
+
def embed_stack_in_json_response?
|
3
|
+
return true if Rails.env.development?
|
4
|
+
Rails.env.production? && ["true", "t", "1", "yes"].include?(params[:debug].to_s.downcase.strip)
|
5
|
+
end
|
6
|
+
|
7
|
+
## This method will accept a proc, execute it and render the json
|
8
|
+
def render_json_response(proc_code)
|
9
|
+
|
10
|
+
begin
|
11
|
+
proc_code.call
|
12
|
+
@success = @success == false ? (false) : (true)
|
13
|
+
rescue Exception => e
|
14
|
+
@success = false
|
15
|
+
@errors = {
|
16
|
+
heading: I18n.translate("api.general.unexpected_failure.heading"),
|
17
|
+
message: I18n.translate("api.general.unexpected_failure.message"),
|
18
|
+
details: e.message,
|
19
|
+
stacktrace: (embed_stack_in_json_response? ? e.backtrace : nil)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
@status ||= 200
|
23
|
+
|
24
|
+
response_hash = {success: @success}
|
25
|
+
response_hash[:alert] = @alert unless @alert.blank?
|
26
|
+
response_hash[:data] = @data unless @data.blank?
|
27
|
+
response_hash[:errors] = @errors unless @errors.blank?
|
28
|
+
|
29
|
+
response_hash[:total_data] = @total_data unless @total_data.blank?
|
30
|
+
response_hash[:per_page] = @per_page unless @per_page.blank?
|
31
|
+
response_hash[:current_page] = @current_page unless @current_page.blank?
|
32
|
+
|
33
|
+
render status: @status, json: response_hash
|
34
|
+
return
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def breadcrumbs_configuration
|
40
|
+
{
|
41
|
+
heading: "Usman - API Documentation",
|
42
|
+
description: "A brief documentation of all APIs implemented in the gem Usman with input and output details and examples",
|
43
|
+
links: []
|
44
|
+
}
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
unless defined?(negative_case)
|
3
|
+
negative_case = false
|
4
|
+
end
|
5
|
+
panel_class = negative_case ? "panel-negative" : "panel-positive"
|
6
|
+
%>
|
7
|
+
|
8
|
+
<div class="panel panel-default <%= panel_class %>" style="width:100%;">
|
9
|
+
<div class="panel-heading">
|
10
|
+
<h4 class="panel-title">
|
11
|
+
<a data-toggle="collapse" data-parent="#<%= example_id %>" href="#<%= example_id %>" class="collapsed" aria-expanded="false">
|
12
|
+
<%= api_title %>
|
13
|
+
</a>
|
14
|
+
</h4>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div id="<%= example_id %>" class="panel-collapse collapse" aria-expanded="false" style="height: 0px;">
|
18
|
+
<div class="panel-body">
|
19
|
+
<br><br><div class="mt-10 mb-20">Input</div><br>
|
20
|
+
<pre class="prettyprint lang-js" style="padding: 20px;border: 0px solid #888;background-color: aliceblue;"><%= api_input %></pre>
|
21
|
+
|
22
|
+
<br><br><div class="mt-10 mb-20">Output</div><br>
|
23
|
+
<pre class="prettyprint lang-js" style="padding: 20px;border: 0px solid #888;background-color: aliceblue;"><%= api_output %></pre>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
</div>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<ul class="nav tabs-vertical">
|
2
|
+
<li class="<%= nav_active?('docs/end_point_1') ? 'active' : '' %>">
|
3
|
+
<a href="/docs/api/v1/end_point_1">
|
4
|
+
<i class="fa-globe visible-xs"></i>
|
5
|
+
<span class="hidden-xs">API End Point 1</span>
|
6
|
+
</a>
|
7
|
+
</li>
|
8
|
+
<li class="<%= nav_active?('docs/end_point_2') ? 'active' : '' %>">
|
9
|
+
<a href="/docs/api/v1/end_point_1">
|
10
|
+
<i class="fa-globe visible-xs"></i>
|
11
|
+
<span class="hidden-xs">API End Point 2</span>
|
12
|
+
</a>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
|
16
|
+
<style type="text/css">
|
17
|
+
.panel-positive h4.panel-title a { color: #68b828 !important; }
|
18
|
+
.panel-negative h4.panel-title a { color: #cc3f44 !important; }
|
19
|
+
</style>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<div class="tabs-vertical-env">
|
2
|
+
|
3
|
+
<%= render partial: "kuppayam/api/docs/navigation" %>
|
4
|
+
|
5
|
+
<div class="tab-content">
|
6
|
+
<div class="tab-pane active" id="<%= params[:action] %>">
|
7
|
+
|
8
|
+
<h3><span class="text-success"><%= @title %></span></h3>
|
9
|
+
<p><code><strong><%= @request_type %></strong> <%= request.base_url %><%= @end_point %></code></p>
|
10
|
+
|
11
|
+
<% if @description %>
|
12
|
+
<p class="text-primary"><%= @description %></p>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<% if @warning %>
|
16
|
+
<p class="alert alert-danger mt-40"><%= @warning %></p>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<% if @info %>
|
20
|
+
<p class="alert alert-info mt-40"><%= @info %></p>
|
21
|
+
<% end %>
|
22
|
+
|
23
|
+
<br>
|
24
|
+
|
25
|
+
<% if @input_headers && @input_headers.any? %>
|
26
|
+
<h4 style="color:#4b4b4b">Headers</h4>
|
27
|
+
|
28
|
+
<div class="table-responsive table-scrollable">
|
29
|
+
<table class="table table-striped table-condensed table-bordered">
|
30
|
+
<thead>
|
31
|
+
<tr>
|
32
|
+
<th>Key</th>
|
33
|
+
<th>Value</th>
|
34
|
+
<th>Description</th>
|
35
|
+
</tr>
|
36
|
+
</thead>
|
37
|
+
|
38
|
+
<tbody>
|
39
|
+
<% @input_headers.each do |key, value| %>
|
40
|
+
<tr>
|
41
|
+
<td style="width:160px;"><%= key.to_s.titleize %></td>
|
42
|
+
<td style="width:160px;"><%= value[:value] %></td>
|
43
|
+
<td><%= value[:description] %></td>
|
44
|
+
</tr>
|
45
|
+
<% end %>
|
46
|
+
</tbody>
|
47
|
+
</table>
|
48
|
+
</div>
|
49
|
+
<% end %>
|
50
|
+
|
51
|
+
<% if @input_params && @input_params.any? %>
|
52
|
+
<h4 style="color:#4b4b4b">Input Parameters</h4>
|
53
|
+
|
54
|
+
<div class="table-responsive table-scrollable">
|
55
|
+
<table class="table table-striped table-condensed table-bordered">
|
56
|
+
<thead>
|
57
|
+
<tr>
|
58
|
+
<th>Name</th>
|
59
|
+
<th>Mandatory</th>
|
60
|
+
<th>Description</th>
|
61
|
+
<th>Example</th>
|
62
|
+
<th>Default</th>
|
63
|
+
</tr>
|
64
|
+
</thead>
|
65
|
+
|
66
|
+
<tbody>
|
67
|
+
<% @input_params.each do |key, value| %>
|
68
|
+
<tr>
|
69
|
+
<td style="width:160px;"><%= key.to_s.camelcase %></td>
|
70
|
+
<td style="width:100px;"><%= value[:mandatory] %></td>
|
71
|
+
<td><%= value[:description] %></td>
|
72
|
+
<td style="width:200px;"><%= value[:example] %></td>
|
73
|
+
<td style="width:100px;"><%= value[:default] %></td>
|
74
|
+
</tr>
|
75
|
+
<% end %>
|
76
|
+
</tbody>
|
77
|
+
</table>
|
78
|
+
</div>
|
79
|
+
<% end %>
|
80
|
+
|
81
|
+
<% if @examples && @examples.any? %>
|
82
|
+
<br><br><br>
|
83
|
+
<h4 style="color:#4b4b4b">Examples</h4>
|
84
|
+
<br>
|
85
|
+
|
86
|
+
<div class="panel-group panel-group-joined">
|
87
|
+
<% @examples.each do |e| %>
|
88
|
+
<%= render partial: "#{@example_path}/#{params[:action]}/#{e}" %>
|
89
|
+
<% end %>
|
90
|
+
</div>
|
91
|
+
<% end %>
|
92
|
+
</div>
|
93
|
+
</div>
|
94
|
+
</div>
|
File without changes
|
@@ -0,0 +1,30 @@
|
|
1
|
+
en:
|
2
|
+
status:
|
3
|
+
success: "Success!"
|
4
|
+
error: "Error! Need your attention!"
|
5
|
+
internal_server_error: "500 - Something went wrong."
|
6
|
+
forbidden: "403 - Permission Denied! You don't have permission to perform this action."
|
7
|
+
not_found: "404 - Not Found: We don't have what you are looking for."
|
8
|
+
invalid_authenticity_token_heading: "Invalid Authenticity Token"
|
9
|
+
invalid_authenticity_token_message: "The Page / Action you have requested is not available at this moment. Please try again after refreshing the page."
|
10
|
+
invalid_token:
|
11
|
+
heading: "Invalid Authentation Token"
|
12
|
+
message: "The Page / Action you have requested is not available at this moment. Please try again after refreshing the page."
|
13
|
+
errors:
|
14
|
+
errors_highlighted: "You have few errors. They have been highlighted."
|
15
|
+
failed_to_save: "Failed to save %{item}."
|
16
|
+
failed_to_create: "Failed to create %{item}."
|
17
|
+
failed_to_update: "Failed to update %{item}."
|
18
|
+
failed_to_delete: "Failed to delete %{item}. Please delete all associated data with the %{item} and try again."
|
19
|
+
success:
|
20
|
+
saved: "%{item} has been saved successfully."
|
21
|
+
added: "%{item} has been added successfully."
|
22
|
+
created: "%{item} has been created successfully."
|
23
|
+
updated: "%{item} has been updated successfully."
|
24
|
+
deleted: "%{item} has been deleted successfully."
|
25
|
+
removed: "%{item} has been removed successfully."
|
26
|
+
uploaded: "%{item} has been uploaded successfully."
|
27
|
+
no_results_found: "No results found."
|
28
|
+
state:
|
29
|
+
changed: "%{item} has been %{new_state}."
|
30
|
+
|
data/lib/kuppayam/engine.rb
CHANGED
data/lib/kuppayam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuppayam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -392,6 +392,7 @@ files:
|
|
392
392
|
- app/helpers/navigation_helper.rb
|
393
393
|
- app/helpers/notification_helper.rb
|
394
394
|
- app/helpers/params_parser_helper.rb
|
395
|
+
- app/helpers/render_api_helper.rb
|
395
396
|
- app/helpers/render_helper.rb
|
396
397
|
- app/helpers/resource_helper.rb
|
397
398
|
- app/models/document/base.rb
|
@@ -410,6 +411,9 @@ files:
|
|
410
411
|
- app/views/kaminari/_page.html.erb
|
411
412
|
- app/views/kaminari/_paginator.html.erb
|
412
413
|
- app/views/kaminari/_prev_page.html.erb
|
414
|
+
- app/views/kuppayam/api/docs/_example.html.erb
|
415
|
+
- app/views/kuppayam/api/docs/_navigation.html.erb
|
416
|
+
- app/views/kuppayam/api/docs/show.html.erb
|
413
417
|
- app/views/kuppayam/documents/_crop_form.html.erb
|
414
418
|
- app/views/kuppayam/documents/_form.html.erb
|
415
419
|
- app/views/kuppayam/documents/_new.html.erb
|
@@ -483,7 +487,12 @@ files:
|
|
483
487
|
- config/initializers/importer.rb
|
484
488
|
- config/initializers/inflections.rb
|
485
489
|
- config/initializers/validators.rb
|
486
|
-
- config/locales/kuppayam/
|
490
|
+
- config/locales/kuppayam/activerecord.ar.yml
|
491
|
+
- config/locales/kuppayam/activerecord.en.yml
|
492
|
+
- config/locales/kuppayam/api.ar.yml
|
493
|
+
- config/locales/kuppayam/api.en.yml
|
494
|
+
- config/locales/kuppayam/general.ar.yml
|
495
|
+
- config/locales/kuppayam/general.en.yml
|
487
496
|
- config/routes.rb
|
488
497
|
- db/migrate/20170000000000_create_images.rb
|
489
498
|
- db/migrate/20170000000001_create_documents.rb
|