bfdotcom-theme 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3ed6dafdbe7d4d9dd22ba315097fc9109bc3f1eb9ed3048a2d0751db601a9a1
4
- data.tar.gz: 9ba384c05c0071d723db0781a53a710243a4201ae30740befbd9f3d9d2b2dc5f
3
+ metadata.gz: a9d2a2c39581e1026c30257d9a75d355af70f879141197db1834dc9d63494c38
4
+ data.tar.gz: b5ac571664a46c26957502ae2f851849d4db6d46923b5fdb8602c0fa4dfa5793
5
5
  SHA512:
6
- metadata.gz: 10f3865e753672adda051b25d433720f136c3e387ef70621278992af0ce5b994bab9ea78fb96d8de87aa049bb26cc5f3cf7cdbbcaecb3cf5864289863897de47
7
- data.tar.gz: 174a32ecb39bf26f65102464b16dd927767ad734a1cac27404e01ae4a2f2baebc796a5a0c86c1d1be3fdba71412b98839161a369f71ce45f60f049029a8ca844
6
+ metadata.gz: 82ab9e538266083d2832225091b699302062275aa2065c1d4ae16346b4f9beed1cc7788fdec3414a9138279801e273967b0f57e3ffbc3573867eb8c24141f643
7
+ data.tar.gz: b7edbdf2e2a3b518a3d0dd4d5bf71a4aed1ae093b3a24c297d07d450c92d840dc00011cf80849123c7b4ab90df1de63075123a6ef2cf78f93442fc02d5171977
@@ -13,9 +13,22 @@
13
13
 
14
14
  <div class="showSignedIn row">
15
15
  <div class="col">
16
- You're signed in as <span id="currentUserName"></span>, and the new comment form is coming soon, I promise! <br />
17
- <a href="#" onclick="signOut()">Sign out</a>
16
+ <p>You're signed in as <span id="currentUserName"></span> | <a href="#" onclick="signOut()">Sign out</a></p>
17
+ <div class="form-group">
18
+ <label for="commentText">Comment</label>
19
+ <textarea class="form-control" id="commentText" rows="3"></textarea>
20
+ </div>
21
+ <button type="button" class="btn btn-outline-info" id="submitButton" onclick="submitComment()">Add your comment</button>
18
22
  </div>
23
+ <div class="spinner-border" role="status" id="submittingComment">
24
+ <span class="sr-only">Submitting comment...</span>
25
+ </div>
26
+ <div class="alert alert-success" role="alert" id="commentSuccess">
27
+ Your comment has been submitted - it will appear here after it has been approved.
28
+ </div>
29
+ <div class="alert alert-danger" role="alert" id="commentError">
30
+ There was an error submitting your comment, sorry!
31
+ </div>
19
32
  </div>
20
33
 
21
34
  {%- if comments_size > 0 -%}
@@ -34,4 +47,8 @@
34
47
  {%- endfor -%}
35
48
  {%- endif -%}
36
49
 
50
+ {%- if comments_size = 0 -%}
51
+ <p>There are no comments on this post yet. Be the first to leave one!</p>
52
+ {%- endif -%}
53
+
37
54
  <p>&nbsp;</p>
@@ -90,6 +90,109 @@ function addMinutes(date, minutes) {
90
90
  return new Date(date + minutes*60000)
91
91
  }
92
92
 
93
+ var apigClientFactory = {};
94
+ apigClientFactory.newClient = function (config) {
95
+ var apigClient = { };
96
+ if(config === undefined) {
97
+ config = {
98
+ accessKey: '',
99
+ secretKey: '',
100
+ sessionToken: '',
101
+ region: aws_region,
102
+ apiKey: undefined,
103
+ defaultContentType: 'application/json',
104
+ defaultAcceptType: 'application/json'
105
+ };
106
+ }
107
+ if(config.accessKey === undefined) {
108
+ config.accessKey = '';
109
+ }
110
+ if(config.secretKey === undefined) {
111
+ config.secretKey = '';
112
+ }
113
+ if(config.apiKey === undefined) {
114
+ config.apiKey = '';
115
+ }
116
+ if(config.sessionToken === undefined) {
117
+ config.sessionToken = '';
118
+ }
119
+ if(config.region === undefined) {
120
+ config.region = aws_region;
121
+ }
122
+ //If defaultContentType is not defined then default to application/json
123
+ if(config.defaultContentType === undefined) {
124
+ config.defaultContentType = 'application/json';
125
+ }
126
+ //If defaultAcceptType is not defined then default to application/json
127
+ if(config.defaultAcceptType === undefined) {
128
+ config.defaultAcceptType = 'application/json';
129
+ }
130
+ // extract endpoint and path from url
131
+ var invokeUrl = api_gateway_url;
132
+ var endpoint = /(^https?:\/\/[^\/]+)/g.exec(invokeUrl)[1];
133
+ var pathComponent = invokeUrl.substring(endpoint.length);
134
+ var sigV4ClientConfig = {
135
+ accessKey: config.accessKey,
136
+ secretKey: config.secretKey,
137
+ sessionToken: config.sessionToken,
138
+ serviceName: 'execute-api',
139
+ region: config.region,
140
+ endpoint: endpoint,
141
+ defaultContentType: config.defaultContentType,
142
+ defaultAcceptType: config.defaultAcceptType
143
+ };
144
+ var authType = 'NONE';
145
+ if (sigV4ClientConfig.accessKey !== undefined && sigV4ClientConfig.accessKey !== '' && sigV4ClientConfig.secretKey !== undefined && sigV4ClientConfig.secretKey !== '') {
146
+ authType = 'AWS_IAM';
147
+ }
148
+ var simpleHttpClientConfig = {
149
+ endpoint: endpoint,
150
+ defaultContentType: config.defaultContentType,
151
+ defaultAcceptType: config.defaultAcceptType
152
+ };
153
+ var apiGatewayClient = apiGateway.core.apiGatewayClientFactory.newClient(simpleHttpClientConfig, sigV4ClientConfig);
154
+ apigClient.commentsPost = function (params, body, additionalParams) {
155
+ if(additionalParams === undefined) { additionalParams = {}; }
156
+ apiGateway.core.utils.assertParametersDefined(params, [], ['body']);
157
+ var commentsPostRequest = {
158
+ verb: 'post'.toUpperCase(),
159
+ path: pathComponent + uritemplate('/comments').expand(apiGateway.core.utils.parseParametersToObject(params, [])),
160
+ headers: apiGateway.core.utils.parseParametersToObject(params, []),
161
+ queryParams: apiGateway.core.utils.parseParametersToObject(params, []),
162
+ body: body
163
+ };
164
+ return apiGatewayClient.makeRequest(commentsPostRequest, authType, additionalParams, config.apiKey);
165
+ };
166
+ return apigClient;
167
+ };
168
+
169
+ function submitComment() {
170
+ var commentText = $('#commentText').text()
171
+ var userInfo = getUserInfo()
172
+ $('#submitButton').hide()
173
+ $('#commentText').hide()
174
+ $('#submittingComment').show()
175
+ var apigClient = apigClientFactory.newClient();
176
+ apigClient.commentsPost({}, {
177
+ "authorName": userInfo.name,
178
+ "authorEmail": userInfo.email,
179
+ "postUrl": window.location.pathname,
180
+ "comment": commentText
181
+ }, additionalParams)
182
+ .then(function(result){
183
+ //This is where you would put a success callback
184
+ $('#commentSuccess').show()
185
+ $('#submittingComment').hide()
186
+ }).catch( function(result){
187
+ //This is where you would put an error callback
188
+ $('#commentError').show()
189
+ $('#submittingComment').hide()
190
+ });
191
+ }
192
+
93
193
  $(document).ready(function() {
94
194
  refreshSignedInStatus()
195
+ $('#commentSuccess').hide()
196
+ $('#commentError').hide()
197
+ $('#submittingComment').hide()
95
198
  })
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bfdotcom-theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Farnhill