mddir 0.1.0 → 0.2.1
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 +9 -0
- data/README.md +22 -3
- data/lib/mddir/cli.rb +7 -0
- data/lib/mddir/collection.rb +1 -0
- data/lib/mddir/fetcher.rb +16 -1
- data/lib/mddir/server.rb +1 -0
- data/lib/mddir/version.rb +1 -1
- data/lib/mddir.rb +0 -3
- 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: e6aac0b080aaf3ec9e7b1c912cfabed017b5379610be25ba5ccf865925b061f7
|
|
4
|
+
data.tar.gz: 7a80416b4d19a80e6de0448877b5f6d9b8ab650ed967ae231579fe808c7cbd69
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fcade5ae9ef5dbc11091d817efcdf82bb4a848a9540dac5f9e919afc95b8ccd46b0b96106872af66d0490f9180fa9e4c699ba51cbe5fbe100d1e59689774f78e
|
|
7
|
+
data.tar.gz: ae7f69a7861fb375b45aa7abf64ae781429121cc49053c37cc5d943be02af1765118ed7f4043292b40f813fe34bc18af203370336ee83ffcf6fba2dd1dbf9b9a
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.1] - 2026-03-01
|
|
4
|
+
|
|
5
|
+
- Fix broken image markdown from pages using `<picture>` elements (e.g. Substack)
|
|
6
|
+
|
|
7
|
+
## [0.2.0] - 2026-03-01
|
|
8
|
+
|
|
9
|
+
- Lazy load dependencies to speed up Tebako binaries
|
|
10
|
+
- Add Tebako CI workflow for building standalone binaries
|
|
11
|
+
|
|
3
12
|
## [0.1.0] - 2026-02-28
|
|
4
13
|
|
|
5
14
|
- Fetch web pages and convert to clean markdown
|
data/README.md
CHANGED
|
@@ -17,15 +17,32 @@ mddir fetches web pages, converts them to clean markdown, and organizes them int
|
|
|
17
17
|
|
|
18
18
|
## Installation
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
### Homebrew (macOS)
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
|
|
23
|
+
brew install AliOsm/tap/mddir
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Standalone Binary (macOS & Linux)
|
|
27
|
+
|
|
28
|
+
Download the latest binary for your platform from the [GitHub releases page](https://github.com/AliOsm/mddir/releases), then:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# macOS: remove the quarantine flag
|
|
32
|
+
xattr -d com.apple.quarantine mddir
|
|
33
|
+
|
|
34
|
+
chmod +x mddir
|
|
35
|
+
sudo mv mddir /usr/local/bin/
|
|
24
36
|
```
|
|
25
37
|
|
|
26
|
-
|
|
38
|
+
On Linux, skip the `xattr` step.
|
|
39
|
+
|
|
40
|
+
### RubyGems
|
|
41
|
+
|
|
42
|
+
Requires Ruby >= 3.2.0. If you don't have Ruby installed, [mise](https://mise.jdx.dev) is the easiest way to get it:
|
|
27
43
|
|
|
28
44
|
```bash
|
|
45
|
+
mise use --global ruby@3
|
|
29
46
|
gem install mddir
|
|
30
47
|
```
|
|
31
48
|
|
|
@@ -142,6 +159,8 @@ mddir add docs https://private.example.com/page --cookies ~/cookies.txt
|
|
|
142
159
|
- [ ] Archive mode to save raw HTML alongside markdown
|
|
143
160
|
- [ ] Migration command to relocate the base directory
|
|
144
161
|
- [ ] Collection pinning and sorting in the web UI
|
|
162
|
+
- [ ] GitHub sync (or GitLab, etc.)
|
|
163
|
+
- [ ] Move entries between collections
|
|
145
164
|
|
|
146
165
|
## Development
|
|
147
166
|
|
data/lib/mddir/cli.rb
CHANGED
|
@@ -36,6 +36,11 @@ module Mddir
|
|
|
36
36
|
desc "collection SUBCOMMAND", "Manage collections"
|
|
37
37
|
subcommand "collection", CollectionCLI
|
|
38
38
|
|
|
39
|
+
desc "version", "Print version"
|
|
40
|
+
def version
|
|
41
|
+
puts "mddir #{Mddir::VERSION}"
|
|
42
|
+
end
|
|
43
|
+
|
|
39
44
|
desc "add COLLECTION URL [URL...]", "Fetch web pages and save to a collection"
|
|
40
45
|
method_option :cookies, type: :string, desc: "Path to a cookies file"
|
|
41
46
|
def add(collection_name, *urls)
|
|
@@ -47,6 +52,7 @@ module Mddir
|
|
|
47
52
|
collection = Collection.new(collection_name, config)
|
|
48
53
|
collection.create! unless collection.exist?
|
|
49
54
|
|
|
55
|
+
require_relative "fetcher"
|
|
50
56
|
fetcher = Fetcher.new(config, cookies_path: options[:cookies])
|
|
51
57
|
urls.each { |url| fetch_and_save(url, collection, fetcher) }
|
|
52
58
|
end
|
|
@@ -86,6 +92,7 @@ module Mddir
|
|
|
86
92
|
collection_name = args.length >= 2 ? args[0] : nil
|
|
87
93
|
query = args.length >= 2 ? args[1..].join(" ") : args[0]
|
|
88
94
|
|
|
95
|
+
require_relative "search"
|
|
89
96
|
results = Search.new(config).search(query, collection_name:)
|
|
90
97
|
results.empty? ? say("No matches found") : print_search_results(results)
|
|
91
98
|
end
|
data/lib/mddir/collection.rb
CHANGED
data/lib/mddir/fetcher.rb
CHANGED
|
@@ -128,7 +128,8 @@ module Mddir
|
|
|
128
128
|
def process_html_response(url, response)
|
|
129
129
|
html = normalize_encoding(response.body.to_s, response.headers["content-type"])
|
|
130
130
|
document = Nokogiri::HTML(html)
|
|
131
|
-
|
|
131
|
+
simplify_image_markup(document)
|
|
132
|
+
title, article_html = extract_readable_content(document.to_html, document)
|
|
132
133
|
markdown = html_to_markdown(article_html)
|
|
133
134
|
|
|
134
135
|
Entry.new(
|
|
@@ -142,6 +143,20 @@ module Mddir
|
|
|
142
143
|
)
|
|
143
144
|
end
|
|
144
145
|
|
|
146
|
+
def simplify_image_markup(document)
|
|
147
|
+
document.css("picture").each do |picture|
|
|
148
|
+
img = picture.at("img")
|
|
149
|
+
img ? picture.replace(img) : picture.remove
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
document.css("a").each do |a|
|
|
153
|
+
img = a.at("img")
|
|
154
|
+
next unless img
|
|
155
|
+
|
|
156
|
+
a.replace(img) if a.text.strip.empty?
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
145
160
|
def extract_readable_content(html, document)
|
|
146
161
|
title, article_html = run_readability(html)
|
|
147
162
|
|
data/lib/mddir/server.rb
CHANGED
data/lib/mddir/version.rb
CHANGED
data/lib/mddir.rb
CHANGED
|
@@ -6,9 +6,6 @@ require_relative "mddir/config"
|
|
|
6
6
|
require_relative "mddir/global_index"
|
|
7
7
|
require_relative "mddir/collection"
|
|
8
8
|
require_relative "mddir/entry"
|
|
9
|
-
require_relative "mddir/fetcher"
|
|
10
|
-
require_relative "mddir/search_index"
|
|
11
|
-
require_relative "mddir/search"
|
|
12
9
|
require_relative "mddir/cli"
|
|
13
10
|
|
|
14
11
|
module Mddir
|