hugo_insert_image.rb

画像をリサイズして取ってくるやつその2 require 'rmagick' require 'date' require 'fileutils' require 'optparse' # gem install clipboard; 要 gem # sudo apt install xsel; 要 xsel require 'clipboard' # default resize 大きさ = 480 mysize = 480 opt = OptionParser.new opt.on('-r', '--resize VALUE', 'リサイズする大きさ(px)') { |v| mysize = v.to_i } # opt.on('-t', '--target DIR', '出力先ディレクトリ') { |v| target = v.to_s } begin opt.parse(ARGV) rescue OptionParser::InvalidOption => e abort "無効なオプション指定が含まれています" end # 移動先は /yymmdd/ date_dir = %Q(#{Date.today.strftime("%Y%m%d")}) # target_dir = ~/blog/static/images/yymmdd target_dir = File.expand_path("~/blog/static/images/#{date_dir}") # ディレクトリが無ければ作る FileUtils.mkdir_p(target_dir) unless File.exist?(target_dir) ARGV.each do |f| if File.extname(f).downcase =~ /.jpe?g|.png/ then #add .png img = Magick::ImageList.new(f) # mysizeより小さい画像は大きくなるのでresizeしない。 img = img.resize_to_fit(mysize, mysize) if [img.rows, img.columns].max > mysize img = img.auto_orient.strip! image_file_name = %Q(#{File.basename(f, ".*")}.webp) img.write(target_dir + "/" + image_file_name) # Clipboardにshortcodeを入れる 実際の使用には '/*'と'*/'を削除する必要あり Clipboard.copy(%Q({{< figure src="/images/#{date_dir}/#{image_file_name}" alt="" title="" width="#{img.rows}" height="#{img.columns}" >}})) # メッセージ puts %Q[#{Clipboard.paste} が clipboard に入ったよ〜] end end 変更履歴 2024-10-14 Monday 画像サイズを指定する ...

6月 5, 2024 · @tsut

2024-06-04 Tuesday

今日の一行ニュース 「会議を開くには至らない」…10年後!?50万円!?墨塗り!? 今日のあれこれ 単管パイプとクランプ、ゴミ箱の土台に使ってたやつ、要らねえから持ってくか?だって。とりあえず「はい」って答える。何に使うかは考え中。自分でバラせってよ。 今日のhugoさん メニューとか付けてみた。どうでしょう? config.toml [[Menus.main]] Name = "トップ" URL = "/" weight = 1 [[Menus.main]] Name = "カテゴリー" URL = "/categories" weight = 2 [[Menus.main]] Name = "タグ" URL = "/tags" weight = 3 今日のごはん 朝: たらこ 油揚げと大根の味噌汁 ひじきの煮物 ご飯 笹団子 昼: ゆで卵 ハンバーグ ブロッコリー ひじきの煮物 ご飯 晩: ぎす煮物 高野豆腐と根菜の煮物 卵焼き 青菜と油揚げの炒めもの きんぴらごぼう 雲丹のっけご飯 今日もとりあえず飲まない 86日目

6月 4, 2024 · @tsut

org-modeでhugoする

hugoを使ってorg-modeをhtmlとかにするってことだが、いまいち良くわからない。画像とかリンクとかをなんとかしたいだけなのにいちいち悩む。調べて、やってみたことを記す。参考は こちら(ショートコード | Hugo)とか。 以下、あまり自信なし。 ショートコード {{% shortcodename arguments %}} ショートコードネームと引数との区切り(前後も含め)スペース必須 ショートコードをそのまま表示する 2024-06-05 追記 HugoでShortcode(ショートコード)をそのまま表示する方法 -STYSK BLOG ショートコード名を/* */で括れ! リンク 外部リンク 普通にorg-modeのリンクの書き方でOK。 [[https://gohugo.io/content-management/shortcodes/][ショートコード | Hugo]] ショートコード | Hugo サイト内リンク この間のあれ [[{{% ref "/posts/202405311307.20240531.org" %}}][この間のあれ]] サイト内アンカーへのリンク1 [[{{% ref "/posts/202406101814.journal.org#headline-3" %}}][エアコンから水漏れ]] リンク先のhtmlソースを見ないとIDがわからない。面倒。 エアコンから水漏れ 画像 hugo 標準のディレクトリ構成で "~/blog/static/images" に画像ファイルを置いた場合。例はこの前のラーメン写真。 {{&lt;figure src="/images/20240601/DSC_0384.JPG" alt="今日のお昼"&gt;}} "<"、">"をエスケープしています。そのまんま表示する方法がわからない(泣)。 脚注とかもわからない(泣)。 /* */で括ってみた。↓ ...

6月 2, 2024 · @tsut

hugoの使い方

hugoでの記事作成 M-x my/easy-hugo-newpost すっかり忘れてる…(泣) 参考:hugoとorg-modeの融合(URLの変更) - (仮) ちょっと訂正 init.el で ↓ のようにしてるから新しいポストは M-x easy-hugo-newpost でおk(たぶん?) (advice-add 'easy-hugo-newpost :override 'my/easy-hugo-newpost) つーことで M-x easy-hugo からメニューをたどって [n . . new blog post] ってするってこと。

9月 28, 2022 · @tsut

そらこて、ねっ!

sorakote.net sorakote.net やったこと レンタルサーバーの引っ越し m10.coreserver.jp => v2005.coreserver.jp ドメイン取得 バリュードメインで適当に sorakote.net とかしてみた 日記のようなものを復旧 gem 'tdiary-style-emptdiary'をGemfileに追記 - bundle config set path 'vendor/bundle' - bundle config set --local without 'development' - bundle install --without development とりあえず動くことを確認 Netlifyのhugoをsorakote.netに value-domain.comのネームサーバーをdns1〜4.p03.nsone.netとかに書き換えてしまう sorakote.netでhugo表示できる これで良いならレンタルサーバーとかいらねんじゃね?(Netlifyとvalue-domainしか使ってない)と、気づく あたりまえに 日記のようなものはディレクトリごと消えてる サブディレクトリ 【Netlify】サブディレクトリにページをデプロイする方法 | みどりみちのブログ なんかいけそうな感じ、これで行くか…、保険でとっとく サブドメイン やったことないやつ たぶん、できるとうれしい つーことでこれ試す value-domain.com の [DNSレコード/URL転送の設定]でcnameを指定してみる a @ xxx.xx.xxx.xx a www xxx.xx.xxx.xx cname blog dazzling-knuth-e5f641.netlify.app. aaaa @ xxxx:xxxx:xxxx:xxx::ss:x aaaa www xxxx:xxxx:xxxx:xxx::ss:x mx @ 10 txt @ v=spf1 ip4:xxx.xx.xxx.xx ip6:xxxx:xxxx:xxxx:xxx::xx:x ~all 日記のようなものの再設定 適当なバックアップを適当にアップロードしたけどうまく動かず… ここ参考に(まんまそのまんま)、いちから再インストールして復旧。 思ったこと

9月 28, 2022 · @tsut