diff options
author | mms <git@sapka.me> | 2024-12-02 23:58:55 +0100 |
---|---|---|
committer | mms <git@sapka.me> | 2024-12-02 23:58:55 +0100 |
commit | 05fa3943852767b848d430eccedbc3b018615229 (patch) | |
tree | 68560eda968619003af563ee51d2b00fe507db6c | |
parent | 00c47d0161b9d1cb652b35e3c4466e235c98a3cb (diff) |
feat: bookmarks
-rw-r--r-- | assets/more/bookmarks.yml | 32 | ||||
-rwxr-xr-x | bin/bookmark | 14 | ||||
-rw-r--r-- | layouts/shortcodes/bookmark-month.html | 4 | ||||
-rw-r--r-- | layouts/shortcodes/bookmarks-all.html | 3 |
4 files changed, 48 insertions, 5 deletions
diff --git a/assets/more/bookmarks.yml b/assets/more/bookmarks.yml index 830abc1..9701679 100644 --- a/assets/more/bookmarks.yml +++ b/assets/more/bookmarks.yml @@ -62,10 +62,40 @@ bookmarks: date: '2024-11-26' host: textfiles.com - url: https://news.slashdot.org/story/24/11/28/1831249/coffee-at-highest-price-in-47-years - title: Coffee at Highest Price in 47 years - Slashdot + title: Coffee at Highest Price in 47 years date: '2024-11-28' host: news.slashdot.org - url: https://www.latimes.com/entertainment-arts/business/story/2024-12-02/the-casual-moviegoer-is-a-thing-of-the-past-thats-a-big-problem-for-hollywood title: The casual moviegoer is a thing of the past. That's a problem for Hollywood date: '2024-12-02' host: latimes.com +- url: https://sfconservancy.org/news/2024/nov/29/openwrt-one-wireless-router-now-ships-black-friday/ + title: First Router Designed Specifically For OpenWrt Released + date: '2024-12-02' + host: sfconservancy.org +- url: https://www.servethehome.com/the-apple-mac-mini-m4-sets-the-mini-computer-standard/ + title: The Apple Mac Mini M4 Sets the Mini Computer Standard + date: '2024-12-02' + host: servethehome.com +- url: https://www.youtube.com/watch?v=VUFOSJZJVM4 + title: Worlds of Ultima Retrospective | Savage Empire & Martian Dreams + date: '2024-12-02' + host: youtube.com +- url: https://abnml.com/blog/2024/11/26/replacing-proxmox-with-freebsd-and-bhyve/ + title: Replacing Proxmox with FreeBSD and Bhyve - ABNML + date: '2024-12-02' + host: abnml.com + source_url: https://vermaden.wordpress.com/2024/12/02/valuable-news-2024-12-02/ + source_host: vermaden.wordpress.com +- url: https://no-color.org/ + title: 'NO_COLOR: disabling ANSI color output by default' + date: '2024-12-02' + host: no-color.org + source_url: https://jcs.org/projects + source_host: jcs.org +- url: https://9to5google.com/2024/11/25/google-ios-app-link-annotations-search/ + title: Google app for iOS now injects links back to Search on websites + date: '2024-12-02' + host: 9to5google.com + source_url: https://tech.slashdot.org/story/24/11/26/0029213/googles-ios-app-now-injects-links-on-third-party-websites-that-go-back-to-search + source_host: tech.slashdot.org diff --git a/bin/bookmark b/bin/bookmark index f6d389b..eb22730 100755 --- a/bin/bookmark +++ b/bin/bookmark @@ -8,7 +8,7 @@ require 'open-uri' require 'openssl' require 'yaml' -Bookmark = Struct.new(:url, :title, :date, :host) +Bookmark = Struct.new(:url, :title, :date, :host, :source_url, :source_host) bookmark = Bookmark.new(date: Time.now.strftime('%Y-%m-%d')) OptionParser.new do |opts| opts.banner = 'Usage: bookmark [options]' @@ -16,21 +16,27 @@ OptionParser.new do |opts| opts.on('-uURL', '--url=URL', 'Url of the new bookmark') do |n| bookmark[:url] = n end + + opts.on('-sURL', '--source=URL', 'Url of the source') do |n| + bookmark[:source_url] = n + end end.parse! bookmark.host = URI.parse(bookmark[:url]).host.gsub(/^www\./, '') +bookmark.source_host = URI.parse(bookmark[:source_url]).host.gsub(/^www\./, '') if bookmark[:source_url] URI.parse(bookmark[:url]).open({ ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE }) do |page| noko = Nokogiri::HTML(page) - title = noko.xpath('//title').first.content + title = noko.xpath('//title').first.content - # remove known page title craps - title = case bookmark.host + # remove known page title craps + title = case bookmark.host when 'brainbaking.com' then title.gsub(/\s\|\sBrain Baking$/, '') when 'vermaden.wordpress.com' then title.gsub(/\s\|\s𝚟𝚎𝚛𝚖𝚊𝚍𝚎𝚗$/, '') when 'youtube.com' then title.gsub(/\s-|\sYouTube$/, '') when 'blog.thechases.com' then title.gsub(/\s\|\sTim's blog$/, '') when 'arstechnica.com' then title.gsub(/\s-\sArs Technica$/, '') + when 'servethehome.com' then title.gsub(/\s-\sServeTheHome$/, '') else title end diff --git a/layouts/shortcodes/bookmark-month.html b/layouts/shortcodes/bookmark-month.html index 499f538..480f6e8 100644 --- a/layouts/shortcodes/bookmark-month.html +++ b/layouts/shortcodes/bookmark-month.html @@ -12,6 +12,10 @@ <a href="{{ .url }}">{{ .title }}</a> ({{ .host }}) + {{ if .source_url }} + (<a href="{{ .source_url }}">via {{ .source_host }}</a>) + {{ end }} + {{ end }} {{ end }} </ul> diff --git a/layouts/shortcodes/bookmarks-all.html b/layouts/shortcodes/bookmarks-all.html index 92a2d55..b1fd562 100644 --- a/layouts/shortcodes/bookmarks-all.html +++ b/layouts/shortcodes/bookmarks-all.html @@ -9,6 +9,9 @@ - <a href="{{ .url }}">{{ .title }}</a> ({{ .host }}) + {{ if .source_url }} + (<a href="{{ .source_url }}">via {{ .source_host }}</a>) + {{ end }} {{ end }} </ul> |