bridgetown-notable 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '0379d2ac8d8a87960f01fe34d75f20c4d35874818925abe86a734d20a3efa96e'
4
+ data.tar.gz: ba49a85179b0465c2cb083644d6c92966a4036cd5de6b3d08b0daf9b967c6687
5
+ SHA512:
6
+ metadata.gz: 73843321577332b6f85c7a3b9ea861a0c59a81e2b8e6f5575ba25899dbf7a47c9fc20fc31c2eb2ea4ae84eafdfa1a195b55249d1403f68b1730e60ec543ec228
7
+ data.tar.gz: 525c000c77255ddac827ea5f377789bf7944587608944c029077b5efa29e74eaf73f88eae4402236cb22111b74789ebfbc4334fb8f788aeffa23c1228c4908e0
@@ -0,0 +1,38 @@
1
+ /vendor
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
16
+ *.gem
17
+ Gemfile.lock
18
+ .bundle
19
+ .ruby-version
20
+
21
+ # Node
22
+ node_modules
23
+ .npm
24
+ .node_repl_history
25
+
26
+ # Yarn
27
+ yarn-error.log
28
+ yarn-debug.log*
29
+ .pnp/
30
+ .pnp.js
31
+
32
+ # Yarn Integrity file
33
+ .yarn-integrity
34
+
35
+ spec/dest
36
+ .bridgetown-metadata
37
+ .bridgetown-cache
38
+ .bridgetown-webpack
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,22 @@
1
+ require: rubocop-bridgetown
2
+
3
+ inherit_gem:
4
+ rubocop-bridgetown: .rubocop.yml
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.5
8
+ Include:
9
+ - lib/**/*.rb
10
+
11
+ Exclude:
12
+ - .gitignore
13
+ - .rspec
14
+ - .rubocop.yml
15
+
16
+ - Gemfile.lock
17
+ - CHANGELOG.md
18
+ - LICENSE.txt
19
+ - README.md
20
+
21
+ - script/**/*
22
+ - vendor/**/*
@@ -0,0 +1,6 @@
1
+ # master
2
+
3
+ # 0.1.0 / 2020-05-01
4
+
5
+ * First version
6
+ * Supports hosting a Notable data directory in `src/`, such that `src/notes` holds note entries, and `src/attachments` holds attachments.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
5
+
6
+ gem "bridgetown", ENV["BRIDGETOWN_VERSION"] if ENV["BRIDGETOWN_VERSION"]
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020-present
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,71 @@
1
+ # Notable for Bridgetown
2
+
3
+ A Bridgetown plugin to host notes and attachments from [Notable](https://notable.app/), a markdown-based editor.
4
+
5
+ ## Installation
6
+
7
+ Run this command to add this plugin to your site's Gemfile:
8
+
9
+ ```shell
10
+ $ bundle add bridgetown-notable -g bridgetown_plugins
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ Currently supports hosting a single Notable data directory at `src/`, such that `src/notes` holds note entries, and `src/attachments` holds attachments.
16
+
17
+ Requires a bit of setup in bridgetown.config.yml:
18
+
19
+ ```yaml
20
+ defaults:
21
+ - scope:
22
+ path: notes/
23
+ values:
24
+ notable: true
25
+ layout: notable
26
+ ```
27
+
28
+ By setting `notable: true` on pages, this plugin will:
29
+
30
+ - format `[[wikilinks]]` between Notable pages, with `<a class="wikilink"` to hook in styles if desired
31
+ - update markdown links/images from `@attachment` to a path Bridgetown can find
32
+ - track backlinks in `page.backlinks` if that's your thing
33
+
34
+ You can specify any layout you want, it's provided a `page` object like any other.
35
+
36
+ <!--
37
+ ### Optional configuration options
38
+
39
+ The plugin will automatically use any of the following metadata variables if they are present in your site's `_data/site_metadata.yml` file.
40
+
41
+ … None yet -->
42
+
43
+ ## Testing
44
+
45
+ * Run `bundle exec rspec` to run the test suite
46
+ * Or run `script/cibuild` to validate with Rubocop and test with rspec together.
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it (https://github.com/jamie/bridgetown-notable/fork)
51
+ 2. Clone the fork using `git clone` to your local development machine.
52
+ 3. Create your feature branch (`git checkout -b my-new-feature`)
53
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
54
+ 5. Push to the branch (`git push origin my-new-feature`)
55
+ 6. Create a new Pull Request
56
+
57
+ ----
58
+
59
+ ## Releasing (you can delete this section in your own plugin repo)
60
+
61
+ To release a new version of the plugin, simply bump up the version number in both `version.rb` and
62
+ `package.json`, and then run `script/release`. This will require you to have a registered account
63
+ with both the [RubyGems.org](https://rubygems.org) and [NPM](https://www.npmjs.com) registries.
64
+ You can optionally remove the `package.json` and `frontend` folder if you don't need to package frontend
65
+ assets for Webpack.
66
+
67
+ If you run into any problems or need further guidance, please check out our [Bridgetown community resources](https://www.bridgetownrb.com/docs/community)
68
+ where friendly folks are standing by to help you build and release your plugin or theme.
69
+
70
+ **NOTE:** make sure you add the `bridgetown-plugin` [topic](https://github.com/topics/bridgetown-plugin) to your
71
+ plugin's GitHub repo so the plugin or theme will show up on [Bridgetown's official Plugin Directory](https://www.bridgetownrb.com/plugins)! (There may be a day or so delay before you see it appear.)
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task :default => :spec
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bridgetown-notable/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bridgetown-notable"
7
+ spec.version = BridgetownNotable::VERSION
8
+ spec.author = "Jamie Macey"
9
+ spec.email = "jamie.git@tracefunc.com"
10
+ spec.summary = "Plugin to host a Notable data directory"
11
+ spec.homepage = "https://github.com/jamie/bridgetown-notable"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r!^(test|script|spec|features|frontend)/!) }
15
+ spec.test_files = spec.files.grep(%r!^spec/!)
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.required_ruby_version = ">= 2.5.0"
19
+
20
+ spec.add_dependency "bridgetown", ">= 0.15", "< 2.0"
21
+
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "nokogiri", "~> 1.6"
24
+ spec.add_development_dependency "rake", "~> 12.0"
25
+ spec.add_development_dependency "rspec", "~> 3.0"
26
+ spec.add_development_dependency "rubocop-bridgetown", "~> 0.2"
27
+ end
File without changes
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bridgetown"
4
+ require "bridgetown-notable/builder"
5
+
6
+ Bridgetown::PluginManager.new_source_manifest(
7
+ origin: BridgetownNotable,
8
+ components: File.expand_path("../components", __dir__),
9
+ content: File.expand_path("../content", __dir__),
10
+ layouts: File.expand_path("../layouts", __dir__)
11
+ )
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgetownNotable
4
+ class Builder < Bridgetown::Builder
5
+ LINK_PATTERN = %r!\[\[([^\]]+)\]\]!.freeze
6
+
7
+ def build
8
+ generator :attachments
9
+ generator :backlinks
10
+ generator :wikilinks
11
+ end
12
+
13
+ def attachments
14
+ notable_pages.each do |page|
15
+ page.content.gsub!("(@attachment/", "(/attachments/")
16
+ end
17
+ end
18
+
19
+ def backlinks
20
+ notable_pages.each do |page|
21
+ pagename = page.data[:title]
22
+ backlinks = site.pages.select { |pg| pg.content =~ %r!\[\[#{pagename}\]\]!i }
23
+ page.data[:backlinks] = backlinks if backlinks.any?
24
+ end
25
+ end
26
+
27
+ def wikilinks
28
+ notable_pages.each do |page|
29
+ page.content.gsub!(LINK_PATTERN) do |match_string|
30
+ title = match_string.match(LINK_PATTERN)[1]
31
+ link = site.pages.detect { |pg| pg.data[:title] == title }
32
+ if link
33
+ %(<a href="#{link.url}" class="wikilink">#{link.data[:title]}</a>)
34
+ else
35
+ title
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ private
42
+
43
+ def notable_pages
44
+ site.pages.select { |page| notable?(page) }
45
+ end
46
+
47
+ def notable?(page)
48
+ page.data[:notable]
49
+ end
50
+ end
51
+ end
52
+
53
+ BridgetownNotable::Builder.register
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module BridgetownNotable
4
+ VERSION = "0.1.0"
5
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bridgetown-notable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jamie Macey
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bridgetown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0.15'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0.15'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: nokogiri
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.6'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.6'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '12.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '12.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '3.0'
89
+ - !ruby/object:Gem::Dependency
90
+ name: rubocop-bridgetown
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '0.2'
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.2'
103
+ description:
104
+ email: jamie.git@tracefunc.com
105
+ executables: []
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".rubocop.yml"
112
+ - CHANGELOG.md
113
+ - Gemfile
114
+ - LICENSE.txt
115
+ - README.md
116
+ - Rakefile
117
+ - bridgetown-notable.gemspec
118
+ - content/template/.keep
119
+ - lib/bridgetown-notable.rb
120
+ - lib/bridgetown-notable/builder.rb
121
+ - lib/bridgetown-notable/version.rb
122
+ homepage: https://github.com/jamie/bridgetown-notable
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 2.5.0
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.0.3
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Plugin to host a Notable data directory
145
+ test_files: []