bkmrq 0.0.6 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +13 -0
- data/Gemfile.lock +70 -0
- data/LICENSE +21 -0
- data/README.md +74 -0
- data/bin/bkmrq +4 -3
- data/bkmrq.gemspec +28 -0
- data/lib/bkmrq/application.rb +27 -0
- data/lib/bkmrq/bookmark.rb +35 -0
- data/lib/bkmrq/cli/app.rb +17 -0
- data/lib/bkmrq/cli/arg_parser.rb +90 -0
- data/lib/bkmrq/codegen/html_generator.rb +26 -0
- data/lib/bkmrq/codegen/markdown_generator.rb +78 -0
- data/lib/bkmrq/error.rb +8 -0
- data/lib/bkmrq/extractors/brave.rb +29 -0
- data/lib/bkmrq/extractors/chrome.rb +29 -0
- data/lib/bkmrq/extractors/chromium.rb +30 -0
- data/lib/bkmrq/extractors/error.rb +13 -0
- data/lib/bkmrq/extractors/extractors.rb +21 -0
- data/lib/bkmrq/extractors/firefox.rb +29 -0
- data/lib/bkmrq/extractors/opera.rb +29 -0
- data/lib/bkmrq/extractors/safari.rb +24 -0
- data/lib/bkmrq/filter.rb +14 -0
- data/lib/bkmrq/formatters/assets.rb +11 -0
- data/lib/bkmrq/formatters/csv.rb +12 -0
- data/lib/bkmrq/formatters/formatters.rb +18 -0
- data/lib/bkmrq/formatters/html.rb +43 -0
- data/lib/bkmrq/formatters/json.rb +28 -0
- data/lib/bkmrq/formatters/markdown.rb +50 -0
- data/lib/bkmrq/parsers/brave.rb +52 -0
- data/lib/bkmrq/parsers/chrome.rb +52 -0
- data/lib/bkmrq/parsers/chromium.rb +52 -0
- data/lib/bkmrq/parsers/error.rb +13 -0
- data/lib/bkmrq/parsers/firefox.rb +19 -0
- data/lib/bkmrq/parsers/opera.rb +19 -0
- data/lib/bkmrq/parsers/parsers.rb +22 -0
- data/lib/bkmrq/parsers/safari.rb +19 -0
- data/lib/bkmrq/ui.rb +39 -0
- data/lib/bkmrq/writer.rb +12 -0
- data/lib/bkmrq.rb +7 -5
- metadata +76 -13
- data/lib/bkmrq/app.rb +0 -83
- data/lib/bkmrq/browser_config.rb +0 -24
- data/lib/bkmrq/cli.rb +0 -52
- data/lib/bkmrq/docs_template.rb +0 -31
- data/lib/bkmrq/manual.rb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52e4d9801b5317a0b8f27cdffc18d50cf95e00e468f28574996491c51930fd3b
|
4
|
+
data.tar.gz: d62d04d10c4695b913dd6b5c7a6db0f4d58af0f39838420dfd894e5865690f4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43ec26e9947af243651a640b9a48b22a54a72266e378b338f30037451a29c56751de3bae5c9b2d00a4b8e546cfa6ec7cb655dfd3155ca3f9111ff9d0d9f8300d
|
7
|
+
data.tar.gz: ca6ac79634e312e52cbe32c3acc9682316cdd213cbd3c4a5ca23dd7c23b58db8bd0cee326bbe097edc474ac8a73ead924c88a69d8e25e3432d154eb145e1aad9
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gem 'oj'
|
6
|
+
gem 'progress_bar'
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem 'rspec', '~> 3.12.0'
|
10
|
+
gem 'rubocop', '~> 1.59.0'
|
11
|
+
gem 'rubocop-performance', '~> 1.15.2'
|
12
|
+
gem 'rubocop-rspec', '~> 2.18.1'
|
13
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.4.2)
|
5
|
+
diff-lcs (1.5.0)
|
6
|
+
highline (2.1.0)
|
7
|
+
json (2.6.3)
|
8
|
+
oj (3.14.1)
|
9
|
+
options (2.3.2)
|
10
|
+
parallel (1.22.1)
|
11
|
+
parser (3.2.0.0)
|
12
|
+
ast (~> 2.4.1)
|
13
|
+
progress_bar (1.3.3)
|
14
|
+
highline (>= 1.6, < 3)
|
15
|
+
options (~> 2.3.0)
|
16
|
+
rainbow (3.1.1)
|
17
|
+
regexp_parser (2.6.2)
|
18
|
+
rexml (3.2.5)
|
19
|
+
rspec (3.12.0)
|
20
|
+
rspec-core (~> 3.12.0)
|
21
|
+
rspec-expectations (~> 3.12.0)
|
22
|
+
rspec-mocks (~> 3.12.0)
|
23
|
+
rspec-core (3.12.1)
|
24
|
+
rspec-support (~> 3.12.0)
|
25
|
+
rspec-expectations (3.12.2)
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
+
rspec-support (~> 3.12.0)
|
28
|
+
rspec-mocks (3.12.3)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.12.0)
|
31
|
+
rspec-support (3.12.0)
|
32
|
+
rubocop (1.44.1)
|
33
|
+
json (~> 2.3)
|
34
|
+
parallel (~> 1.10)
|
35
|
+
parser (>= 3.2.0.0)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
regexp_parser (>= 1.8, < 3.0)
|
38
|
+
rexml (>= 3.2.5, < 4.0)
|
39
|
+
rubocop-ast (>= 1.24.1, < 2.0)
|
40
|
+
ruby-progressbar (~> 1.7)
|
41
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
42
|
+
rubocop-ast (1.24.1)
|
43
|
+
parser (>= 3.1.1.0)
|
44
|
+
rubocop-capybara (2.17.0)
|
45
|
+
rubocop (~> 1.41)
|
46
|
+
rubocop-performance (1.15.2)
|
47
|
+
rubocop (>= 1.7.0, < 2.0)
|
48
|
+
rubocop-ast (>= 0.4.0)
|
49
|
+
rubocop-rspec (2.18.1)
|
50
|
+
rubocop (~> 1.33)
|
51
|
+
rubocop-capybara (~> 2.17)
|
52
|
+
ruby-progressbar (1.11.0)
|
53
|
+
rubytree (2.0.2)
|
54
|
+
json (~> 2.0, > 2.3.1)
|
55
|
+
unicode-display_width (2.4.2)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
x86_64-linux
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
oj
|
62
|
+
progress_bar
|
63
|
+
rspec
|
64
|
+
rubocop
|
65
|
+
rubocop-performance
|
66
|
+
rubocop-rspec
|
67
|
+
rubytree
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
2.3.26
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 Sreedev Kodichath
|
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,74 @@
|
|
1
|
+
# bkmrq
|
2
|
+
bkmrq `(pronounced bookmark)` is a command-line tool for organizing and transferring bookmarks across multiple browsers including Chrome, Firefox, Safari, and Opera. With just a few simple commands, export bookmarks in JSON, Markdown, CSV, and HTML formats. Ideal for automated scripts and command line users, it's fast and efficient. Specify format and location to easily transfer bookmarks, perfect for backups and sharing.
|
3
|
+
|
4
|
+
# Disclaimer
|
5
|
+
This project is still under development. If you would like to contribute, please checkout [CONTRIBUTING.md]().
|
6
|
+
Bkmrq Currently only supports the following browsers
|
7
|
+
- Brave (Default Profile Only)
|
8
|
+
- Chromium (Default Profile Only)
|
9
|
+
- Chrome (Default Profile Only)
|
10
|
+
|
11
|
+
The following formats are supported for exporting bookmarks
|
12
|
+
- markdown
|
13
|
+
- json
|
14
|
+
- html
|
15
|
+
|
16
|
+
# Installation
|
17
|
+
Running Bkmrq requires ruby installed (>= 3.0.0)
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install bkmrq
|
21
|
+
```
|
22
|
+
|
23
|
+
# Usage
|
24
|
+
```
|
25
|
+
___ __
|
26
|
+
/ _ )/ /__ __ _ _______ _
|
27
|
+
/ _ / '_// ' \/ __/ _ `/
|
28
|
+
/____/_/\_\/_/_/_/_/ \_, /
|
29
|
+
/_/
|
30
|
+
# Examples
|
31
|
+
--------------------------------
|
32
|
+
# Export Bookmarks from Brave Browser in Markdown format
|
33
|
+
$ bkmrq export --to=brave_bookmarks.md --browser=brave --format=markdown
|
34
|
+
|
35
|
+
# Export Bookmarks from Chromium Browser
|
36
|
+
# in Markdown format & exclude bookmarks/folders with the word "php" and "java"
|
37
|
+
$ bkmrq export --to=chromium_books.md --browser=chromium --format=markdown --exclude="php,java"
|
38
|
+
--------------------------------
|
39
|
+
|
40
|
+
# Supported Browsers(--browser=)
|
41
|
+
- brave
|
42
|
+
- chromium
|
43
|
+
- chrome
|
44
|
+
- firefox
|
45
|
+
- opera
|
46
|
+
- safari (mac only)
|
47
|
+
|
48
|
+
# Supported Export Formats (--format=)
|
49
|
+
- markdown
|
50
|
+
- json
|
51
|
+
- html
|
52
|
+
- csv
|
53
|
+
|
54
|
+
# OPTIONS:
|
55
|
+
-o, --to=FILEPATH save the export file to <FILEPATH>
|
56
|
+
-b, --browser=BROWSER export bookmarks from <BROWSER>
|
57
|
+
-f, --format=FILEFORMAT export bookmarks to <FORMAT> File.
|
58
|
+
-x, --exclude=XPATTERNS exclude bookmarks or folders containing <KEYWORDS>
|
59
|
+
-v, --version Print Version
|
60
|
+
-h, --help Print help docs
|
61
|
+
```
|
62
|
+
|
63
|
+
# Examples
|
64
|
+
An example markdown file generated using this gemfile is available [here](https://github.com/sreedevk/bookmarks/blob/main/README.md)
|
65
|
+
|
66
|
+
Export bookmarks from `Brave Browser` in `markdown` format to `brave_bookmarks.md` file
|
67
|
+
```bash
|
68
|
+
$ bkmrq -b brave -f markdown -o brave_bookmarks.md
|
69
|
+
```
|
70
|
+
|
71
|
+
Export bookmarks from `Brave Browser` in `json` format to `brave_bookmarks.json` file
|
72
|
+
```bash
|
73
|
+
$ bkmrq -b brave -f json -o brave_bookmarks.json
|
74
|
+
```
|
data/bin/bkmrq
CHANGED
data/bkmrq.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'bkmrq'
|
5
|
+
s.version = '0.1.1'
|
6
|
+
s.licenses = ['MIT']
|
7
|
+
s.summary = 'Cross browser multi-format bookmarks exporter'
|
8
|
+
s.description = <<~DESC
|
9
|
+
The Bookmark Exporter CLI is a command-line tool for organizing and transferring
|
10
|
+
bookmarks across multiple browsers including Chrome, Firefox, Safari, and Opera.
|
11
|
+
With just a few simple commands, export bookmarks in JSON, Markdown, CSV, and HTML formats.
|
12
|
+
Ideal for automated scripts and command line users, it's fast and efficient.
|
13
|
+
DESC
|
14
|
+
s.authors = ['sreedev <sreedevpadmakumar@gmail.com>']
|
15
|
+
s.email = 'sreedevpadmakumar@gmail.com'
|
16
|
+
s.homepage = 'https://rubygems.org/gems/bkmrq'
|
17
|
+
s.metadata = { 'source_code_uri' => 'https://github.com/sreedevk/bkmrq' }
|
18
|
+
s.executables = ['bkmrq']
|
19
|
+
s.require_paths = ['lib']
|
20
|
+
s.files = [
|
21
|
+
Dir['lib/**/*'].keep_if { |file| File.file?(file) },
|
22
|
+
%w[Gemfile Gemfile.lock LICENSE README.md bkmrq.gemspec]
|
23
|
+
].flatten
|
24
|
+
|
25
|
+
# Dependencies
|
26
|
+
s.add_dependency 'oj', '~> 3.14.1'
|
27
|
+
s.add_dependency 'progress_bar', '~> 1.3.3'
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Application Container
|
4
|
+
module Bkmrq
|
5
|
+
require_relative 'extractors/extractors'
|
6
|
+
require_relative 'parsers/parsers'
|
7
|
+
require_relative 'filter'
|
8
|
+
require_relative 'formatters/formatters'
|
9
|
+
require_relative 'writer'
|
10
|
+
|
11
|
+
# Application Core
|
12
|
+
class Application
|
13
|
+
attr_accessor :opts
|
14
|
+
|
15
|
+
def initialize(opts: {})
|
16
|
+
@opts = opts
|
17
|
+
end
|
18
|
+
|
19
|
+
def export!
|
20
|
+
Bkmrq::Extractors.run(opts)
|
21
|
+
.then { |extracted_file| Bkmrq::Parsers.run(extracted_file, opts) }
|
22
|
+
.then { |parsed_file| Bkmrq::Filter.run(parsed_file, opts) }
|
23
|
+
.then { |filtered_bookmarks| Bkmrq::Formatters.run(filtered_bookmarks, opts) }
|
24
|
+
.then { |formatted_bookmarks| Bkmrq::Writer.run(formatted_bookmarks, opts) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bkmrq
|
4
|
+
# Common Bookmark Format for All Browsers
|
5
|
+
class Bookmark
|
6
|
+
attr_accessor :guid, :url, :name, :created_at, :id, :path
|
7
|
+
|
8
|
+
def initialize(opts)
|
9
|
+
@guid = opts[:guid]
|
10
|
+
@name = opts[:name]
|
11
|
+
@path = opts[:path]
|
12
|
+
@url = opts[:url]
|
13
|
+
@created_at = opts[:created_at]
|
14
|
+
@id = opts[:id]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Bookmark Directory
|
19
|
+
class BookmarkDir
|
20
|
+
attr_accessor :children, :name
|
21
|
+
|
22
|
+
def initialize(name)
|
23
|
+
@name = name
|
24
|
+
@children = Set[]
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_child(child)
|
28
|
+
@children << child
|
29
|
+
end
|
30
|
+
|
31
|
+
def children?
|
32
|
+
@children.any?
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'arg_parser'
|
4
|
+
require_relative '../application'
|
5
|
+
|
6
|
+
module Bkmrq
|
7
|
+
module Cli
|
8
|
+
# Cli Application Interface
|
9
|
+
class App
|
10
|
+
def self.run!
|
11
|
+
Bkmrq::Application
|
12
|
+
.new(opts: Bkmrq::Cli::ArgParser.parse!)
|
13
|
+
.export!
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require_relative '../../bkmrq'
|
5
|
+
require_relative '../ui'
|
6
|
+
|
7
|
+
module Bkmrq
|
8
|
+
module Cli
|
9
|
+
# Argument Parser
|
10
|
+
module ArgParser
|
11
|
+
def self.assign_or_raise_arg(options, key, value)
|
12
|
+
raise OptionParser::MissingArgument if value.blank?
|
13
|
+
|
14
|
+
options[key] = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.filepath_opt(parser)
|
18
|
+
parser.on(
|
19
|
+
'-o',
|
20
|
+
'--to [FILEPATH]',
|
21
|
+
'save the export file to <FILEPATH>'
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.browser_opt(parser)
|
26
|
+
parser.on(
|
27
|
+
'-b',
|
28
|
+
'--browser [BROWSER]',
|
29
|
+
%i[chrome chromium brave firefox safari opera],
|
30
|
+
'export bookmarks from <BROWSER>'
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.format_opt(parser)
|
35
|
+
parser.on(
|
36
|
+
'-f',
|
37
|
+
'--format [FILEFORMAT]',
|
38
|
+
%i[markdown json csv html],
|
39
|
+
'export bookmarks to <FORMAT> File.'
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.exclude_patterns_opt(parser)
|
44
|
+
parser.on(
|
45
|
+
'-x',
|
46
|
+
'--exclude [XPATTERNS]',
|
47
|
+
'exclude bookmarks or folders containing <KEYWORDS>'
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.banner(parser)
|
52
|
+
parser.banner = Bkmrq::Ui::BANNER
|
53
|
+
parser.separator Bkmrq::Ui::USAGE
|
54
|
+
parser.separator "\n\s\s\s\s# OPTIONS:\n"
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.version(parser)
|
58
|
+
parser.on('-v', '--version', 'print bkmrq version') do
|
59
|
+
puts "bkmrq v#{Bkmrq::VERSION}"
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.help(parser)
|
65
|
+
parser.on('-h', '--help', 'print bkmrq help docs') do
|
66
|
+
puts parser
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.generate_opt_parser
|
72
|
+
OptionParser.new do |parser|
|
73
|
+
banner(parser)
|
74
|
+
filepath_opt(parser)
|
75
|
+
browser_opt(parser)
|
76
|
+
format_opt(parser)
|
77
|
+
exclude_patterns_opt(parser)
|
78
|
+
version(parser)
|
79
|
+
help(parser)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.parse!(parsed = {})
|
84
|
+
parsed.tap do |options|
|
85
|
+
generate_opt_parser.parse!(ARGV, into: options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Codegen
|
4
|
+
class HtmlGenerator
|
5
|
+
def self.link(text, url)
|
6
|
+
"<a href=\"#{url}\" target=\"_blank\" rel=\"noopener noreferrer\">#{text}</a>"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.header(text, level)
|
10
|
+
level = 6 if level > 6
|
11
|
+
"<h#{level}>#{text}</h#{level}>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.div
|
15
|
+
<<-HTML
|
16
|
+
<div>#{yield}</div>
|
17
|
+
HTML
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.paragraph
|
21
|
+
<<-HTML
|
22
|
+
<p>#{yield}</p>
|
23
|
+
HTML
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Codegenerator module
|
4
|
+
module Codegen
|
5
|
+
# Generator for markdown
|
6
|
+
class MarkdownGenerator
|
7
|
+
def self.image(url, alt_text)
|
8
|
+
"![#{alt_text}](#{url})"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.title(text, level = 1, id = nil)
|
12
|
+
(('#' * level) + " #{text}") + (id ? "{##{id}}" : '')
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.strikethrough(text)
|
16
|
+
"--#{text}--"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.highlight(text)
|
20
|
+
"==#{text}=="
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.tasklist(items, completed_indices = [])
|
24
|
+
items
|
25
|
+
.map
|
26
|
+
.with_index { |item, index| "- [#{completed_indices.include?(index) ? 'x' : ''}] #{item}" }
|
27
|
+
.join("\n")
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.ordered_list(items)
|
31
|
+
items
|
32
|
+
.map.with_index { |item, index| "#{index.next}. #{item}" }
|
33
|
+
.join("\n")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bold(text)
|
37
|
+
"**#{text}**"
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.blockquote(text)
|
41
|
+
"> #{text}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.code(text)
|
45
|
+
"`#{text}`"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.italic(text)
|
49
|
+
"*#{text}*"
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.horizontal_rule
|
53
|
+
'---'
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.link(text, url)
|
57
|
+
"[#{text}](#{url})"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.line(text)
|
61
|
+
"#{text} "
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.unordered_list(items)
|
65
|
+
items
|
66
|
+
.map { |item| "- #{item}" }
|
67
|
+
.join("\n")
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.codeblock(text, source_lang = '')
|
71
|
+
<<~CDB
|
72
|
+
```#{source_lang}
|
73
|
+
#{text}
|
74
|
+
```
|
75
|
+
CDB
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/bkmrq/error.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'error'
|
4
|
+
|
5
|
+
module Extractors
|
6
|
+
# Chrome Bookmarks Extractor
|
7
|
+
class Brave
|
8
|
+
def self.extract
|
9
|
+
new.extract
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract
|
13
|
+
File.read(bookmarks_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def bookmarks_path
|
17
|
+
case RbConfig::CONFIG['host_os']
|
18
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince/i
|
19
|
+
File.expand_path('~/AppData/Local/BraveSoftware/Brave-Browser/User Data/Default/Bookmarks')
|
20
|
+
when /darwin|mac os/i
|
21
|
+
File.expand_path('~/Library/Application Support/BraveSoftware/Brave-Browser/Default/Bookmarks')
|
22
|
+
when /linux/i, /solaris|bsd/i
|
23
|
+
File.expand_path('~/.config/BraveSoftware/Brave-Browser/Default/Bookmarks')
|
24
|
+
else
|
25
|
+
raise Bkmrq::Extractors::Error, 'bkmrq is not supported on your OS.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'error'
|
4
|
+
|
5
|
+
module Extractors
|
6
|
+
# Chrome Bookmarks Extractor
|
7
|
+
class Chrome
|
8
|
+
def self.extract
|
9
|
+
new.extract
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract
|
13
|
+
File.read(bookmarks_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def bookmarks_path
|
17
|
+
case RbConfig::CONFIG['host_os']
|
18
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince/i
|
19
|
+
File.expand_path('~/AppData/Local/Google/Chrome/User Data/Default/Bookmarks')
|
20
|
+
when /darwin|mac os/i
|
21
|
+
File.expand_path('~/Library/Application Support/Google/Chrome/Default/Bookmarks')
|
22
|
+
when /linux/i, /solaris|bsd/i
|
23
|
+
File.expand_path('~/.config/google-chrome/Default/Bookmarks')
|
24
|
+
else
|
25
|
+
raise Bkmrq::Extractors::Error, 'bkmrq is not supported on your OS.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'error'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
module Extractors
|
7
|
+
# Chrome Bookmarks Extractor
|
8
|
+
class Chromium
|
9
|
+
def self.extract
|
10
|
+
new.extract
|
11
|
+
end
|
12
|
+
|
13
|
+
def extract
|
14
|
+
File.read(bookmarks_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def bookmarks_path
|
18
|
+
case RbConfig::CONFIG['host_os']
|
19
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince/i
|
20
|
+
File.expand_path('~/AppData/Local/Chromium/User Data/Default/Bookmarks')
|
21
|
+
when /darwin|mac os/i
|
22
|
+
File.expand_path('~/Library/Application Support/Chromium/Default/Bookmarks')
|
23
|
+
when /linux/i, /solaris|bsd/i
|
24
|
+
File.expand_path('~/.config/chromium/Default/Bookmarks')
|
25
|
+
else
|
26
|
+
raise Bkmrq::Extractors::Error, 'bkmrq is not supported on your OS.'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Extractors
|
4
|
+
module Bkmrq
|
5
|
+
require_relative 'error'
|
6
|
+
require_relative 'brave'
|
7
|
+
require_relative 'chrome'
|
8
|
+
require_relative 'chromium'
|
9
|
+
require_relative 'firefox'
|
10
|
+
require_relative 'opera'
|
11
|
+
require_relative 'safari'
|
12
|
+
|
13
|
+
# Extracts Bookmarks Cross Platform
|
14
|
+
module Extractors
|
15
|
+
def self.run(opts)
|
16
|
+
Object
|
17
|
+
.const_get("Extractors::#{opts[:browser].capitalize}")
|
18
|
+
.extract
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'error'
|
4
|
+
|
5
|
+
module Extractors
|
6
|
+
# Chrome Bookmarks Extractor
|
7
|
+
class Firefox
|
8
|
+
def self.extract
|
9
|
+
new.extract
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract
|
13
|
+
File.read(bookmarks_path)
|
14
|
+
end
|
15
|
+
|
16
|
+
def bookmarks_path
|
17
|
+
case RbConfig::CONFIG['host_os']
|
18
|
+
when /mswin|msys|mingw|cygwin|bccwin|wince/i
|
19
|
+
File.expand_path('~/AppData/Roaming/Mozilla/Firefox/Profiles/{PROFILE_FOLDER}/bookmarks.html')
|
20
|
+
when /darwin|mac os/i
|
21
|
+
File.expand_path('~/Library/Application Support/Firefox/Profiles/{PROFILE_FOLDER}/bookmarks.html')
|
22
|
+
when /linux/i, /solaris|bsd/i
|
23
|
+
File.expand_path('~/.mozilla/firefox/{PROFILE_FOLDER}/bookmarks.html')
|
24
|
+
else
|
25
|
+
raise Bkmrq::Extractors::Error, 'bkmrq is not supported on your OS.'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|