pinboard_logseq 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e4a903038aeaf0c65d2ceceab053a34eaea8e04e210dfc6b93d2b840390bcb40
4
+ data.tar.gz: c9a95bc053416ffdad3c38fe6d3382a1f165339c454935d5bdbf79e25ba79da0
5
+ SHA512:
6
+ metadata.gz: b1d1a224312dacca546b25210a97fe832e5e3bc68adf61e01a5193b528a8ce1f252606a0ccce19acd35f0f8678294866f83b4361c58e081ae7d4e6baf07426f1
7
+ data.tar.gz: 3a9745cc3fdd04548bac55eddfa0ff63a4f74bcce2ac55596d94b074713065adad1797f71a8f768ba96c42a37e25945a2fb6b25731e1972e6a6ace02c27ce10e
data/.standard.yml ADDED
@@ -0,0 +1,3 @@
1
+ # For available configuration options, see:
2
+ # https://github.com/testdouble/standard
3
+ ruby_version: 2.6
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in pinboard_logseq.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "standard", "~> 1.3"
data/Gemfile.lock ADDED
@@ -0,0 +1,78 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pinboard_logseq (0.1.0)
5
+ activesupport
6
+ sorbet-runtime
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (7.0.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ ast (2.4.2)
17
+ concurrent-ruby (1.1.10)
18
+ debug (1.7.0)
19
+ irb (>= 1.5.0)
20
+ reline (>= 0.3.1)
21
+ i18n (1.12.0)
22
+ concurrent-ruby (~> 1.0)
23
+ io-console (0.6.0)
24
+ irb (1.6.1)
25
+ reline (>= 0.3.0)
26
+ json (2.6.3)
27
+ language_server-protocol (3.17.0.2)
28
+ minitest (5.16.3)
29
+ parallel (1.22.1)
30
+ parser (3.1.3.0)
31
+ ast (~> 2.4.1)
32
+ rainbow (3.1.1)
33
+ rake (13.0.6)
34
+ regexp_parser (2.6.1)
35
+ reline (0.3.2)
36
+ io-console (~> 0.5)
37
+ rexml (3.2.5)
38
+ rubocop (1.39.0)
39
+ json (~> 2.3)
40
+ parallel (~> 1.10)
41
+ parser (>= 3.1.2.1)
42
+ rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml (>= 3.2.5, < 4.0)
45
+ rubocop-ast (>= 1.23.0, < 2.0)
46
+ ruby-progressbar (~> 1.7)
47
+ unicode-display_width (>= 1.4.0, < 3.0)
48
+ rubocop-ast (1.24.0)
49
+ parser (>= 3.1.1.0)
50
+ rubocop-performance (1.15.1)
51
+ rubocop (>= 1.7.0, < 2.0)
52
+ rubocop-ast (>= 0.4.0)
53
+ ruby-progressbar (1.11.0)
54
+ sorbet (0.5.10595)
55
+ sorbet-static (= 0.5.10595)
56
+ sorbet-runtime (0.5.10595)
57
+ sorbet-static (0.5.10595-universal-darwin-21)
58
+ standard (1.19.1)
59
+ language_server-protocol (~> 3.17.0.2)
60
+ rubocop (= 1.39.0)
61
+ rubocop-performance (= 1.15.1)
62
+ tzinfo (2.0.5)
63
+ concurrent-ruby (~> 1.0)
64
+ unicode-display_width (2.3.0)
65
+
66
+ PLATFORMS
67
+ arm64-darwin-21
68
+
69
+ DEPENDENCIES
70
+ debug
71
+ minitest (~> 5.0)
72
+ pinboard_logseq!
73
+ rake (~> 13.0)
74
+ sorbet
75
+ standard (~> 1.3)
76
+
77
+ BUNDLED WITH
78
+ 2.3.26
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Andy Waite
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # pinboard_logseq
2
+
3
+ This gem consumes the JSON export from Pinboard, and formats it as a Markdown file suitable for Logseq.
4
+
5
+ It generates a Markdown file correspond to each month in your Pinboard data. The files are stored in a directory named
6
+ `output/`.
7
+
8
+ Import the files into Logseq by dragging them into the `pages/` directory.
9
+
10
+ If you have a large number of bookmarks, you may want to do this in stages, since it can cause Logseq to become
11
+ unresponsive.
12
+
13
+ ## Installation
14
+
15
+ Install the gem by executing:
16
+
17
+ $ gem install pinboard_logseq
18
+
19
+ ## Usage
20
+
21
+ Pass the path to your JSON export as `IMPORT_FILE`, e.g.
22
+
23
+ ```
24
+ IMPORT_FILE="/Users/me/Desktop/pinboard_export.2022.12.18_23.19.json" pinboard_logseq
25
+ ```
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/andyw8/pinboard_logseq.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/test_*.rb"]
10
+ end
11
+
12
+ require "standard/rake"
13
+
14
+ task default: %i[test standard]
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ #frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ require_relative "../lib/pinboard_logseq/cli"
7
+
8
+ PinboardLogseq::Cli.execute(ARGV)
@@ -0,0 +1,51 @@
1
+ require "json"
2
+ require "date"
3
+ require "active_support/core_ext/integer/inflections"
4
+
5
+ require_relative "pin"
6
+
7
+ module PinboardLogseq
8
+ include T::Sig
9
+
10
+ IMPORT_FILE = ENV.fetch("IMPORT_FILE")
11
+
12
+ class Cli
13
+ def self.execute(args)
14
+ new(args).execute
15
+ end
16
+
17
+ def initialize(args)
18
+ @args = args
19
+ end
20
+
21
+ def execute
22
+ data = JSON.parse(File.read(IMPORT_FILE))
23
+
24
+ pins = data.map { |json| Pin.from_hash(json) }
25
+
26
+ pins_by_year_and_month = pins.group_by { |p| [p.time.year, p.time.month] }
27
+
28
+ pins_by_year_and_month.each do |(year, month), pins|
29
+ content = ""
30
+ pins.each do |pin|
31
+ year = pin.time.strftime("%Y")
32
+ month_name_short = pin.time.strftime("%b")
33
+ day = pin.time.day.ordinalize
34
+ formatted_date = "#{month_name_short} #{day}, #{year}"
35
+ content +=
36
+ "- 🔖 #{pin.description || "No description"}](#{pin.href}) [[#{formatted_date}]] "
37
+ content += "\n> #{pin.extended}" if pin.extended && pin.extended != ""
38
+ tag_bits = pin.tags.map { |t| "[[#{t}]]" }
39
+ tag_bits << "[[Pinboard - To Read]]" if pin.to_read
40
+ content += tag_bits.join(" ")
41
+ content += "\n"
42
+ end
43
+ month_name_long = pins.first.time.strftime("%B")
44
+ File.write(
45
+ "output/Pinboard Import ___ #{year} ___ #{month_name_long}.md",
46
+ content
47
+ )
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,41 @@
1
+ # typed: true
2
+
3
+ require "date"
4
+
5
+ module PinboardLogseq
6
+ class Pin < T::Struct
7
+ include T::Sig
8
+
9
+ const :href, String
10
+ const :description, T.any(String, FalseClass)
11
+ const :extended, String
12
+ const :meta, String
13
+ const :pinboard_hash, String
14
+ const :time, Date
15
+ const :shared, T::Boolean
16
+ const :to_read, T::Boolean
17
+ const :tags, T::Array[String]
18
+
19
+ def self.from_hash(json)
20
+ new(
21
+ href: json["href"],
22
+ description: json["description"],
23
+ extended: json["extended"],
24
+ meta: json["meta"],
25
+ pinboard_hash: json["hash"],
26
+ time: Date.iso8601(json["time"]),
27
+ shared: str_to_bool(json["shared"]),
28
+ to_read: str_to_bool(json["toread"]),
29
+ tags: json["tags"].split(" ")
30
+ )
31
+ end
32
+ end
33
+ end
34
+
35
+ def str_to_bool(str)
36
+ if str == "yes"
37
+ true
38
+ elsif str == "no"
39
+ false
40
+ end
41
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PinboardLogseq
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "pinboard_logseq/version"
4
+
5
+ module PinboardLogseq
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/pinboard_logseq/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'pinboard_logseq'
7
+ spec.version = PinboardLogseq::VERSION
8
+ spec.authors = ['Andy Waite']
9
+ spec.email = ['andyw8@users.noreply.github.com']
10
+
11
+ spec.summary = 'Export from Pinboard to Logseq'
12
+ spec.homepage = 'https://github.com/andyw8/pinboard_logseq'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = '>= 2.6.0'
15
+
16
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(__dir__) do
23
+ `git ls-files -z`.split("\x0").reject do |f|
24
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
25
+ end
26
+ end
27
+ spec.bindir = 'exe'
28
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'activesupport'
32
+ spec.add_dependency 'sorbet-runtime'
33
+ spec.add_development_dependency 'debug'
34
+ spec.add_development_dependency 'sorbet'
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
@@ -0,0 +1,4 @@
1
+ module PinboardLogseq
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pinboard_logseq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andy Waite
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sorbet-runtime
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: debug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sorbet
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - andyw8@users.noreply.github.com
72
+ executables:
73
+ - pinboard_logseq
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".standard.yml"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - exe/pinboard_logseq
84
+ - lib/pinboard_logseq.rb
85
+ - lib/pinboard_logseq/cli.rb
86
+ - lib/pinboard_logseq/pin.rb
87
+ - lib/pinboard_logseq/version.rb
88
+ - pinboard_logseq.gemspec
89
+ - sig/pinboard_logseq.rbs
90
+ homepage: https://github.com/andyw8/pinboard_logseq
91
+ licenses:
92
+ - MIT
93
+ metadata:
94
+ allowed_push_host: https://rubygems.org
95
+ homepage_uri: https://github.com/andyw8/pinboard_logseq
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: 2.6.0
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ requirements: []
111
+ rubygems_version: 3.3.24
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Export from Pinboard to Logseq
115
+ test_files: []