testimonials 0.1.4 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +15 -1
- data/config/routes.rb +4 -2
- data/lib/generators/testimonials/install/templates/initializer.rb +8 -1
- data/lib/testimonials/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ecda947648ca731c693ff54a53100bd3f2636f6df7895ccaa645d1629af3746
|
|
4
|
+
data.tar.gz: eacf73190e337c59bf84a3ae03a52ffe38e3df0f4d442178819404dd0b6b4c9f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c826326840c92f1f424c77b4214ed45f4a5a061daf5b13f4cb389770c65e61fcfe1d2cf5535cb89b9a463e555b2b74496a36fdb61bb365b29ada98398a5d7aae
|
|
7
|
+
data.tar.gz: 6ac3a8b5678fd1b50db8e8a972cdac895b065019af3def391cae0dfa230c98219762b1fed7bb684b7b94aee47202d18af0ac97de440e4c7d2b557bc74f015f9c
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
- **Breaking (API paths):** the read API's collection moved from
|
|
6
|
+
`<mount>/api/testimonials` to `<mount>/api` — so it reads clean under any
|
|
7
|
+
mount instead of echoing the resource name (e.g. `/testimonials/api`
|
|
8
|
+
rather than `/testimonials/api/testimonials`). `<mount>/api/stats` is
|
|
9
|
+
unchanged. Update any hardcoded API URLs. (Off by default: only affects
|
|
10
|
+
apps that set `config.public_api = true` or call the API as an admin.)
|
|
11
|
+
|
|
12
|
+
## 0.1.5
|
|
13
|
+
|
|
14
|
+
- Docs: show how to wire `current_user` with Rails 8's built-in authentication
|
|
15
|
+
(`bin/rails generate authentication`), alongside the existing Devise/Warden
|
|
16
|
+
example — in the README and the generated initializer.
|
|
17
|
+
|
|
3
18
|
## 0.1.4
|
|
4
19
|
|
|
5
20
|
- Validation and submit errors are announced to screen readers: every
|
data/README.md
CHANGED
|
@@ -115,6 +115,20 @@ Testimonials.configure do |config|
|
|
|
115
115
|
end
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
`current_user` (and any admin gate) receives the raw request, so it works
|
|
119
|
+
with whatever auth you have:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
# Devise / Warden:
|
|
123
|
+
config.current_user = ->(request) { request.env["warden"]&.user }
|
|
124
|
+
|
|
125
|
+
# Rails 8 built-in auth (bin/rails generate authentication):
|
|
126
|
+
config.current_user = lambda do |request|
|
|
127
|
+
token = request.cookies["session_token"]
|
|
128
|
+
Session.find_signed(token)&.user if token
|
|
129
|
+
end
|
|
130
|
+
```
|
|
131
|
+
|
|
118
132
|
### Guiding questions, localized
|
|
119
133
|
|
|
120
134
|
The questions shown above the form ("How has %{app} helped you?") fight
|
|
@@ -137,7 +151,7 @@ title/company and photo. Disable with `config.public_collection = false`.
|
|
|
137
151
|
|
|
138
152
|
## The read API
|
|
139
153
|
|
|
140
|
-
- `GET /testimonials/api
|
|
154
|
+
- `GET /testimonials/api` — approved + consented records only;
|
|
141
155
|
filters: `featured=1`, `min_rating=4`, `kind=video`, `limit=12`.
|
|
142
156
|
- `GET /testimonials/api/stats` — `count`, `average_rating`, `ratings_count`,
|
|
143
157
|
`nps_score`.
|
data/config/routes.rb
CHANGED
|
@@ -10,9 +10,11 @@ Testimonials::Engine.routes.draw do
|
|
|
10
10
|
resource :nps, only: :create, controller: 'nps'
|
|
11
11
|
resources :nps_responses, only: :index
|
|
12
12
|
|
|
13
|
-
# Read-only JSON for rendering testimonials anywhere.
|
|
13
|
+
# Read-only JSON for rendering testimonials anywhere. The API root *is* the
|
|
14
|
+
# collection, so it reads clean under any mount: GET "<mount>/api" for the
|
|
15
|
+
# list, "<mount>/api/stats" for the aggregate — no "…/api/testimonials" echo.
|
|
14
16
|
namespace :api do
|
|
15
|
-
|
|
17
|
+
root to: 'testimonials#index'
|
|
16
18
|
get 'stats', to: 'stats#show'
|
|
17
19
|
end
|
|
18
20
|
|
|
@@ -15,7 +15,14 @@ Testimonials.configure do |config|
|
|
|
15
15
|
|
|
16
16
|
# Attribute submissions to a user (optional). Return an object responding
|
|
17
17
|
# to #id, or nil. Receives the request.
|
|
18
|
+
# Devise / Warden:
|
|
18
19
|
# config.current_user = ->(request) { request.env["warden"]&.user }
|
|
20
|
+
#
|
|
21
|
+
# Rails 8 built-in auth (bin/rails generate authentication):
|
|
22
|
+
# config.current_user = lambda do |request|
|
|
23
|
+
# token = request.cookies["session_token"]
|
|
24
|
+
# Session.find_signed(token)&.user if token
|
|
25
|
+
# end
|
|
19
26
|
|
|
20
27
|
# Attribution stored with a signed-in user's submission.
|
|
21
28
|
# config.user_display = ->(user) { { name: user.name, email: user.email } }
|
|
@@ -48,7 +55,7 @@ Testimonials.configure do |config|
|
|
|
48
55
|
# outside the app. Set false to disable.
|
|
49
56
|
# config.public_collection = true
|
|
50
57
|
|
|
51
|
-
# Unauthenticated read access to GET /testimonials/api
|
|
58
|
+
# Unauthenticated read access to GET /testimonials/api and
|
|
52
59
|
# /testimonials/api/stats (approved + consented records only). Off = admins only.
|
|
53
60
|
# config.public_api = false
|
|
54
61
|
|
data/lib/testimonials/version.rb
CHANGED