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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28e9c0901404556fd2aeeef6ccd427029da4d3f50f7fe0e5a55fa66b118cce1e
4
- data.tar.gz: f74a0a254c16cf555c14497a36cc2925e791dcdf3bb5ebcb189cb6b0d2a1fdf1
3
+ metadata.gz: e6aac0b080aaf3ec9e7b1c912cfabed017b5379610be25ba5ccf865925b061f7
4
+ data.tar.gz: 7a80416b4d19a80e6de0448877b5f6d9b8ab650ed967ae231579fe808c7cbd69
5
5
  SHA512:
6
- metadata.gz: a593cff246076103d9348d5281063f63abd56fde7540d5596fd97adae0384f9e7a128546fc22ada3c1349ab1557ac5b4190ceb9ff64ce0c6f68befb1cb629997
7
- data.tar.gz: ce4d88969d6e2054670b32780cd6492d3fb90d41e456322869754d993f8bd74d0934e88b6d6d68c780e5f8e3ac9fc17ef901499d354613e88a118dbcbc2bc112
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
- Requires Ruby >= 3.2.0. If you don't have Ruby installed, [mise](https://mise.jdx.dev) is the easiest way to get it:
20
+ ### Homebrew (macOS)
21
21
 
22
22
  ```bash
23
- mise use --global ruby@3
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
- Then install the gem:
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
@@ -91,6 +91,7 @@ module Mddir
91
91
  def remove!
92
92
  FileUtils.rm_rf(@path)
93
93
  GlobalIndex.update!(config)
94
+ require_relative "search_index"
94
95
  SearchIndex.open(config) { |index| index.remove_collection!(name) }
95
96
  end
96
97
 
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
- title, article_html = extract_readable_content(html, document)
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
@@ -5,6 +5,7 @@ require "kramdown"
5
5
  require "kramdown-parser-gfm"
6
6
  require "rouge"
7
7
  require "uri"
8
+ require_relative "search"
8
9
 
9
10
  module Mddir
10
11
  class Server < Sinatra::Base # rubocop:disable Metrics/ClassLength
data/lib/mddir/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mddir
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mddir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ali Hamdi Ali Fadel