From bb49a252db4f77e20f4db3d6bb0f1493861e01f4 Mon Sep 17 00:00:00 2001 From: Daniel Barber Date: Tue, 8 Oct 2019 23:17:03 -0400 Subject: [PATCH] Remove import content script --- content/import_posts | 33 --------------------------------- 1 file changed, 33 deletions(-) delete mode 100755 content/import_posts diff --git a/content/import_posts b/content/import_posts deleted file mode 100755 index 7ac402f7..00000000 --- a/content/import_posts +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env ruby - -require "fileutils" - -Dir.glob("../../danbarber.me/_posts/*.md").each do |file| - name = file.split("/").last.split(".")[0..-2].join - - FileUtils.mkdir_p("blog/#{name}") - - # Read the file and scan for images - content = File.read(file) - content.scan(/blog\/(.*\.(?:jpg|jpeg|png))/) do |image| - image = image[0] - - if File.exists?("../../danbarber.me/_pictures/blog/#{image}") - FileUtils.cp("../../danbarber.me/_pictures/blog/#{image}", "blog/#{name}") - end - end - - newcontent = content.gsub( - /{% picture [a-z\-]+\s(?:\S+\/)+([^\/]+\.(?:jpg|jpeg|png))\s+(?:alt="([^"]*)"\s+)?%}/m, - ) do |match| - image, alt, caption = match.match(/{% picture [a-z\-]+\s(?:\S+\/)+([^\/]+\.(?:jpg|jpeg|png))\s+(?:alt="([^"]*)"\s+)?%}/m).captures - - <<~TAG - {{< img src="#{image}" alt="#{alt}" caption="#{caption}" >}} - TAG - end - - File.open("blog/#{name}/index.md", "w") do |f| - f.write(newcontent) - end -end