diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..bfa7513 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +articles-html diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..84e0e7e --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +gem "rake" +gem "kramdown" +gem "coderay" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..df70cc1 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + specs: + coderay (1.1.0) + kramdown (1.4.2) + rake (10.3.2) + +PLATFORMS + ruby + +DEPENDENCIES + coderay + kramdown + rake diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..99b4793 --- /dev/null +++ b/Rakefile @@ -0,0 +1,27 @@ +require "kramdown" +require "coderay" +require "fileutils" + +MARKDOWN_FILES = Dir.glob("#{__dir__}/articles/**/*.md") + +task default: :html_files + +desc "Generate HTML files from markdown articles" +task :html_files do + MARKDOWN_FILES.each do |markdown_file| + html_path = markdown_file.sub("/articles/", "/articles-html/").sub(/\.md$/, ".html") + puts "Generating #{html_path}" + FileUtils.mkdir_p(File.dirname(html_path)) + File.open(html_path, "w") do |html_file| + filecontent = File.read(markdown_file) + filecontent = filecontent.gsub("\`\`\`", "~~~") + filecontent = Kramdown::Document.new(filecontent, template: "#{__dir__}/templates/default.html.erb") + html_file.write(filecontent.to_html) + end + end +end + +desc "Delete all generated HTML files" +task :clean do + FileUtils.rm_rf("#{__dir__}/articles-html") +end diff --git a/assets/images/header.png b/assets/images/header.png new file mode 100755 index 0000000..36580e5 Binary files /dev/null and b/assets/images/header.png differ diff --git a/templates/default.html.erb b/templates/default.html.erb new file mode 100755 index 0000000..bd097aa --- /dev/null +++ b/templates/default.html.erb @@ -0,0 +1,421 @@ + + + + Practicing Ruby + + + +
+

Practicing Ruby

+ + <%= @body %> +
+ +