jekyll-formspree 0.0.7 → 0.1.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 +39 -0
- data/LICENSE +21 -0
- data/README.md +111 -0
- data/lib/jekyll/formspree/default.html +11 -0
- data/lib/jekyll/formspree/tag.rb +68 -0
- data/lib/jekyll/formspree/version.rb +7 -0
- data/lib/jekyll-formspree.rb +5 -21
- metadata +42 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34e22818eb005587721e734268e8c3f0adcffcc46078b39c6ad1d492ff94f011
|
|
4
|
+
data.tar.gz: 641872f553ee208e93404b17fe033471c24a68bf0a21feeb7520af8eb677bef9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 186d2a9af84e22a27fffffc67cabf0d663fa2ffa22124bc9a416f3b2b8dcea079130d4e8bf5503f09d88e87d42bd887e0e59739c26b37e3741a3e7e729387c10
|
|
7
|
+
data.tar.gz: d0ebf4133f03b6d99fa8bbdfe74ff77c0b8b2af20f13cf9522277411641a06fc9212c600c9bc20b401721d75b75292a9798297c2b9e765f52844b53777289025
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 — 2026-11-02
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- The default form posts to `https://formspree.io/f/<id>`, the current
|
|
8
|
+
Formspree endpoint, instead of the legacy `https://formspree.io/<id>`.
|
|
9
|
+
The prefix can be changed with `formspree: endpoint:` in `_config.yml`.
|
|
10
|
+
- Custom `_includes/formspree.html` templates are rendered in the page's
|
|
11
|
+
Liquid context: `page`, `site`, `layout` and `{% include %}` now work
|
|
12
|
+
inside them. `formspree_id` is still available, and the new
|
|
13
|
+
`formspree_url` holds the full endpoint URL.
|
|
14
|
+
- The default form uses an `email` input, labels tied to their fields and
|
|
15
|
+
`required` attributes. The form has a `formspree-form` class to style it.
|
|
16
|
+
- `_includes/formspree.html` is also looked up in the site's theme.
|
|
17
|
+
|
|
18
|
+
### Added
|
|
19
|
+
|
|
20
|
+
- A build warning when the form ID is empty, e.g. a missing
|
|
21
|
+
`site.formspree_id`.
|
|
22
|
+
- Tests (Minitest) and CI on Ruby 3.3, 3.4 and 4.0 with Jekyll 4.4, and
|
|
23
|
+
Ruby 3.3 with Jekyll 3.10.
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
|
|
27
|
+
- `{% formspree %}` without an ID now fails with a Liquid syntax error.
|
|
28
|
+
- The plugin no longer modifies the site payload while rendering.
|
|
29
|
+
|
|
30
|
+
### Internal
|
|
31
|
+
|
|
32
|
+
- Code moved to `Jekyll::Formspree::Tag` (no more top-level `Formspree`
|
|
33
|
+
class), with the version in `lib/jekyll/formspree/version.rb`.
|
|
34
|
+
- The gemspec declares its Jekyll (>= 3.8, < 5.0) and Ruby (>= 3.1)
|
|
35
|
+
requirements.
|
|
36
|
+
|
|
37
|
+
## 0.0.7 — 2020-03-27
|
|
38
|
+
|
|
39
|
+
- Last release of the original plugin.
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Elaoin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Jekyll Formspree
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/jekyll-formspree)
|
|
4
|
+
[](https://github.com/Elaoin/jekyll-formspree/actions/workflows/ci.yml)
|
|
5
|
+
|
|
6
|
+
A Jekyll plugin that adds a `{% formspree %}` Liquid tag to render a
|
|
7
|
+
[Formspree](https://formspree.io) contact form.
|
|
8
|
+
|
|
9
|
+
Requires Jekyll 3.8 to 4.x and Ruby 3.1 or later.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add the gem to your `Gemfile`:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
group :jekyll_plugins do
|
|
17
|
+
gem "jekyll-formspree"
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
then run `bundle install`. If you list plugins in `_config.yml`, add it there too:
|
|
22
|
+
|
|
23
|
+
```yaml
|
|
24
|
+
plugins:
|
|
25
|
+
- jekyll-formspree
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> GitHub Pages' built-in Jekyll build only runs [allow-listed plugins](https://pages.github.com/versions/).
|
|
29
|
+
> To use this plugin there, build the site with a GitHub Actions workflow.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
Use your form ID, as shown on Formspree (`https://formspree.io/f/<form ID>`):
|
|
34
|
+
|
|
35
|
+
```liquid
|
|
36
|
+
{% formspree "xyzabcde" %}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
or read it from a variable, for example from `_config.yml` (`formspree_id: xyzabcde`)
|
|
40
|
+
or from the page's front matter:
|
|
41
|
+
|
|
42
|
+
```liquid
|
|
43
|
+
{% formspree site.formspree_id %}
|
|
44
|
+
{% formspree page.form_id %}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
If the ID is empty, the build prints a warning.
|
|
48
|
+
|
|
49
|
+
## Default form
|
|
50
|
+
|
|
51
|
+
Without a custom template, the tag renders:
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<form class="formspree-form" action="https://formspree.io/f/xyzabcde" method="POST" accept-charset="utf-8">
|
|
55
|
+
<label for="formspree-email">Your email</label>
|
|
56
|
+
<input type="email" id="formspree-email" name="email" autocomplete="email" required>
|
|
57
|
+
<label for="formspree-message">Your message</label>
|
|
58
|
+
<textarea id="formspree-message" name="message" rows="5" required></textarea>
|
|
59
|
+
<button type="submit">Send</button>
|
|
60
|
+
</form>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
preceded by a few lines of CSS scoped to `.formspree-form`.
|
|
64
|
+
|
|
65
|
+
## Custom form
|
|
66
|
+
|
|
67
|
+
Create `_includes/formspree.html` in your site (or in your theme). The tag
|
|
68
|
+
renders it in the page's context, so `page`, `site` and `{% include %}`
|
|
69
|
+
work as usual, with two extra variables:
|
|
70
|
+
|
|
71
|
+
| Variable | Value |
|
|
72
|
+
|-----------------|---------------------------------------|
|
|
73
|
+
| `formspree_id` | the form ID |
|
|
74
|
+
| `formspree_url` | `https://formspree.io/f/<form ID>` |
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<form action="{{ formspree_url }}" method="POST">
|
|
78
|
+
<input type="email" name="email" required>
|
|
79
|
+
<textarea name="message" required></textarea>
|
|
80
|
+
<input type="hidden" name="_subject" value="Message from {{ page.title }}">
|
|
81
|
+
<button type="submit">Send</button>
|
|
82
|
+
</form>
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
The endpoint prefix defaults to `https://formspree.io/f/`. To change it:
|
|
88
|
+
|
|
89
|
+
```yaml
|
|
90
|
+
formspree:
|
|
91
|
+
endpoint: https://formspree.io/f/
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Upgrading from 0.0.x
|
|
95
|
+
|
|
96
|
+
- The default form now posts to `https://formspree.io/f/<id>` instead of
|
|
97
|
+
`https://formspree.io/<id>`. Use the form ID shown in your Formspree dashboard.
|
|
98
|
+
- Custom templates keep working unchanged. To use the new endpoint, replace
|
|
99
|
+
`https://formspree.io/{{ formspree_id }}` with `{{ formspree_url }}`.
|
|
100
|
+
|
|
101
|
+
## Development
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
bundle install
|
|
105
|
+
bundle exec rake test
|
|
106
|
+
JEKYLL_VERSION="~> 3.10" bundle update jekyll && bundle exec rake test
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## License
|
|
110
|
+
|
|
111
|
+
MIT, see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
.formspree-form label, .formspree-form input, .formspree-form textarea { display: block; width: 100%; box-sizing: border-box; }
|
|
3
|
+
.formspree-form input, .formspree-form textarea { margin: 0.25em 0 1em; padding: 0.5em; font: inherit; }
|
|
4
|
+
</style>
|
|
5
|
+
<form class="formspree-form" action="{{ formspree_url | escape }}" method="POST" accept-charset="utf-8">
|
|
6
|
+
<label for="formspree-email">Your email</label>
|
|
7
|
+
<input type="email" id="formspree-email" name="email" autocomplete="email" required>
|
|
8
|
+
<label for="formspree-message">Your message</label>
|
|
9
|
+
<textarea id="formspree-message" name="message" rows="5" required></textarea>
|
|
10
|
+
<button type="submit">Send</button>
|
|
11
|
+
</form>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Jekyll
|
|
4
|
+
module Formspree
|
|
5
|
+
# {% formspree "FORM_ID" %} or {% formspree site.formspree_id %}
|
|
6
|
+
#
|
|
7
|
+
# Renders _includes/formspree.html (from the site, then from the theme),
|
|
8
|
+
# or the default form bundled with this gem. The template is rendered in
|
|
9
|
+
# the current Liquid context, so `page`, `site` and `{% include %}` work,
|
|
10
|
+
# with two extra variables:
|
|
11
|
+
#
|
|
12
|
+
# formspree_id the form ID
|
|
13
|
+
# formspree_url the form endpoint, https://formspree.io/f/<id>
|
|
14
|
+
#
|
|
15
|
+
# The endpoint prefix can be changed in _config.yml:
|
|
16
|
+
#
|
|
17
|
+
# formspree:
|
|
18
|
+
# endpoint: https://formspree.io/f/
|
|
19
|
+
class Tag < Liquid::Tag
|
|
20
|
+
DEFAULT_ENDPOINT = "https://formspree.io/f/"
|
|
21
|
+
INCLUDE_NAME = "formspree.html"
|
|
22
|
+
DEFAULT_TEMPLATE = File.expand_path("default.html", __dir__)
|
|
23
|
+
|
|
24
|
+
def initialize(tag_name, markup, parse_context)
|
|
25
|
+
super
|
|
26
|
+
@markup = markup.strip
|
|
27
|
+
raise Liquid::SyntaxError, "Syntax error in 'formspree': usage is {% formspree \"FORM_ID\" %}" if @markup.empty?
|
|
28
|
+
|
|
29
|
+
@id_expression = Liquid::Expression.parse(@markup)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def render(context)
|
|
33
|
+
site = context.registers[:site]
|
|
34
|
+
id = context.evaluate(@id_expression).to_s.strip
|
|
35
|
+
warn_missing_id(context) if id.empty?
|
|
36
|
+
|
|
37
|
+
path = template_path(site)
|
|
38
|
+
template = site.liquid_renderer.file(path).parse(File.read(path, **site.file_read_opts))
|
|
39
|
+
|
|
40
|
+
context.stack do
|
|
41
|
+
context["formspree_id"] = id
|
|
42
|
+
context["formspree_url"] = endpoint(site) + id
|
|
43
|
+
template.render!(context)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def endpoint(site)
|
|
50
|
+
config = site.config["formspree"]
|
|
51
|
+
endpoint = config["endpoint"] if config.is_a?(Hash)
|
|
52
|
+
endpoint.to_s.empty? ? DEFAULT_ENDPOINT : endpoint.to_s
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def template_path(site)
|
|
56
|
+
site.includes_load_paths
|
|
57
|
+
.map { |dir| File.join(dir, INCLUDE_NAME) }
|
|
58
|
+
.find { |path| File.file?(path) } || DEFAULT_TEMPLATE
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def warn_missing_id(context)
|
|
62
|
+
page = context.registers[:page]
|
|
63
|
+
where = page && page["path"] ? " in #{page["path"]}" : ""
|
|
64
|
+
Jekyll.logger.warn "Formspree:", "empty form ID for '{% formspree #{@markup} %}'#{where}"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
data/lib/jekyll-formspree.rb
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
class Formspree < Liquid::Tag
|
|
3
|
-
|
|
4
|
-
def initialize(tagName, content, tokens)
|
|
5
|
-
super
|
|
6
|
-
@content = content
|
|
7
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
8
2
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
site = context.registers[:site]
|
|
13
|
-
tmpl_path = File.join site.in_source_dir(site.config["includes_dir"].to_s), "formspree.html"
|
|
14
|
-
if File.exist?(tmpl_path)
|
|
15
|
-
tmpl = File.read tmpl_path
|
|
16
|
-
tmpl = (Liquid::Template.parse tmpl).render site.site_payload.merge!({"formspree_id" => @formspree_id})
|
|
17
|
-
else
|
|
18
|
-
%Q{<style>.form-container { max-width: 100%; } .form-container input { position: relative; top: 0; left: 0; width: 100%; height: 20px; padding: 0 ; } .form-container textarea { position: relative; top: 0; left: 0; width: 100%; height: 80px; padding: 0; } </style> <form action="https://formspree.io/#{ @formspree_id }" method="POST" class='form-container'> <label>Your email:</label><br /><input type="text" name="_replyto" /> <label>Your message:</label><br /><textarea name="message"></textarea> <button type="submit">Send</button> </form>}
|
|
19
|
-
end
|
|
20
|
-
end
|
|
3
|
+
require "jekyll"
|
|
4
|
+
require_relative "jekyll/formspree/version"
|
|
5
|
+
require_relative "jekyll/formspree/tag"
|
|
21
6
|
|
|
22
|
-
|
|
23
|
-
end
|
|
7
|
+
Liquid::Template.register_tag("formspree", Jekyll::Formspree::Tag)
|
metadata
CHANGED
|
@@ -1,27 +1,58 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-formspree
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Elaoin
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
13
|
-
|
|
11
|
+
date: 2026-11-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: jekyll
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.8'
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '5.0'
|
|
23
|
+
type: :runtime
|
|
24
|
+
prerelease: false
|
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
26
|
+
requirements:
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '3.8'
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '5.0'
|
|
33
|
+
description: Adds a {% formspree %} Liquid tag to Jekyll that renders a Formspree
|
|
34
|
+
contact form, using your own _includes/formspree.html template or a default one.
|
|
14
35
|
email: julien@elaoin.com
|
|
15
36
|
executables: []
|
|
16
37
|
extensions: []
|
|
17
38
|
extra_rdoc_files: []
|
|
18
39
|
files:
|
|
40
|
+
- CHANGELOG.md
|
|
41
|
+
- LICENSE
|
|
42
|
+
- README.md
|
|
19
43
|
- lib/jekyll-formspree.rb
|
|
44
|
+
- lib/jekyll/formspree/default.html
|
|
45
|
+
- lib/jekyll/formspree/tag.rb
|
|
46
|
+
- lib/jekyll/formspree/version.rb
|
|
20
47
|
homepage: https://github.com/Elaoin/jekyll-formspree
|
|
21
48
|
licenses:
|
|
22
49
|
- MIT
|
|
23
|
-
metadata:
|
|
24
|
-
|
|
50
|
+
metadata:
|
|
51
|
+
source_code_uri: https://github.com/Elaoin/jekyll-formspree
|
|
52
|
+
changelog_uri: https://github.com/Elaoin/jekyll-formspree/blob/master/CHANGELOG.md
|
|
53
|
+
bug_tracker_uri: https://github.com/Elaoin/jekyll-formspree/issues
|
|
54
|
+
rubygems_mfa_required: 'true'
|
|
55
|
+
post_install_message:
|
|
25
56
|
rdoc_options: []
|
|
26
57
|
require_paths:
|
|
27
58
|
- lib
|
|
@@ -29,15 +60,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
29
60
|
requirements:
|
|
30
61
|
- - ">="
|
|
31
62
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
63
|
+
version: '3.1'
|
|
33
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
65
|
requirements:
|
|
35
66
|
- - ">="
|
|
36
67
|
- !ruby/object:Gem::Version
|
|
37
68
|
version: '0'
|
|
38
69
|
requirements: []
|
|
39
|
-
rubygems_version: 3.
|
|
40
|
-
signing_key:
|
|
70
|
+
rubygems_version: 3.2.22
|
|
71
|
+
signing_key:
|
|
41
72
|
specification_version: 4
|
|
42
|
-
summary:
|
|
73
|
+
summary: Liquid tag that renders Formspree contact forms in Jekyll sites
|
|
43
74
|
test_files: []
|