Created
May 23, 2020 22:39
-
-
Save hyuki/e67b456e3d9604200eb63de3fb9093ec to your computer and use it in GitHub Desktop.
esa-backlog - 「結城浩の作業ログ」を振り返ってみて「あ、これ、あとでまた見たいな」というときに現在の作業ログからリンクを貼るためのツール。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'cgi' | |
require 'logger' | |
require 'mechanize' | |
if ARGV.length != 1 | |
abort("Usage: esa-backlog https://esa-pages.io/.*.html#文字列") | |
end | |
url = ARGV[0] | |
if !url.match(%r(^https://esa-pages.io/p/sharing/.*\.html#(.*))) | |
abort("Usage: esa-backlog https://esa-pages.io/.*.html#文字列") | |
end | |
caption = CGI.unescape($1) | |
agent = Mechanize.new | |
logger = Logger.new(STDERR) | |
logger.level = Logger::INFO | |
# agent.log = logger | |
page = agent.get(url) | |
title = page.title | |
title.gsub!(/ - esa-pages.io/, '') | |
title.gsub!(%r{結城浩の作業ログ/}, '') | |
title.gsub!(%r{(\d\d\d\d)/(\d\d)/(\d\d)}, '\1年\2月\3日') | |
puts "- [#{caption} - #{title}](#{url})" | |
# vim: set filetype=ruby: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bookmarklet:
https://gist.github.com/hyuki/5bc01c42ea13b367417fa3691bbfea1a