From 7c9e0850a05b23869d81977a3c76a4d4a930eddd Mon Sep 17 00:00:00 2001 From: Nika Zhenya Date: Wed, 20 Mar 2019 02:01:01 -0600 Subject: [PATCH] Desarrollo de 'create-indexes-feeds' --- README.md | 36 + config/build/create-indexes-feeds | 121 +++ config/build/pos2htmls | 39 +- config/template/site/foot.xml | 2 + config/template/site/footer.html | 2 +- config/template/site/head.xml | 15 + config/template/site/header.html | 2 +- config/template/site/main_lang.rb | 24 + content/html/en/_about.html | 6 +- content/html/en/_contact.html | 6 +- content/html/en/_donate.html | 6 +- content/html/en/_fork.html | 6 +- content/html/en/_links.html | 6 +- content/html/en/index.html | 36 + content/html/es/_about.html | 6 +- content/html/es/_contact.html | 6 +- content/html/es/_donate.html | 6 +- content/html/es/_fork.html | 6 +- content/html/es/_links.html | 6 +- content/html/es/index.html | 36 + css/extra.css | 3 + feed/en/rss.xml | 17 + feed/es/rss.xml | 17 + old/README.md | 34 - old/build.rb | 299 ------ old/css/core.css | 824 ----------------- old/css/ebooks.css | 7 - old/css/extra.css | 36 - old/css/styles.css | 817 ---------------- old/ebooks/entry001.epub | Bin 220602 -> 0 bytes old/ebooks/entry001.mobi | Bin 500998 -> 0 bytes old/feed/index.html | 7 - old/feed/rss.xml | 35 - old/html/entry001.html | 38 - old/icon.png | Bin 216337 -> 0 bytes old/img/e001_01.jpg | Bin 21086 -> 0 bytes old/img/e001_02.jpg | Bin 17676 -> 0 bytes old/img/e001_03.jpg | Bin 17767 -> 0 bytes old/index.html | 37 - old/js/main.js | 17 - old/js/piwik.js | 11 - old/md/entry001.md.bak | 325 ------- old/md/entry002.md.bak | 41 - old/src/entry001/data.txt | 43 - old/src/entry001/graphics.ods | Bin 22529 -> 0 bytes old/template/ebooks/svg/cover.svg | 1024 --------------------- old/template/ebooks/xhtml/000-cover.xhtml | 14 - old/template/site/footer.html | 10 - old/template/site/head.html | 16 - old/template/site/header.html | 11 - old/ttf/bitter-bold.ttf | Bin 68284 -> 0 bytes old/ttf/bitter-bolditalic.ttf | Bin 74528 -> 0 bytes old/ttf/bitter-italic.ttf | Bin 74200 -> 0 bytes old/ttf/bitter-regular.ttf | Bin 71920 -> 0 bytes 54 files changed, 348 insertions(+), 3708 deletions(-) create mode 100644 README.md create mode 100755 config/build/create-indexes-feeds create mode 100644 config/template/site/foot.xml create mode 100644 config/template/site/head.xml create mode 100644 config/template/site/main_lang.rb create mode 100644 content/html/en/index.html create mode 100644 content/html/es/index.html create mode 100644 feed/en/rss.xml create mode 100644 feed/es/rss.xml delete mode 100644 old/README.md delete mode 100644 old/build.rb delete mode 100644 old/css/core.css delete mode 100644 old/css/ebooks.css delete mode 100644 old/css/extra.css delete mode 100644 old/css/styles.css delete mode 100644 old/ebooks/entry001.epub delete mode 100644 old/ebooks/entry001.mobi delete mode 100644 old/feed/index.html delete mode 100644 old/feed/rss.xml delete mode 100644 old/html/entry001.html delete mode 100644 old/icon.png delete mode 100644 old/img/e001_01.jpg delete mode 100644 old/img/e001_02.jpg delete mode 100644 old/img/e001_03.jpg delete mode 100644 old/index.html delete mode 100644 old/js/main.js delete mode 100644 old/js/piwik.js delete mode 100644 old/md/entry001.md.bak delete mode 100644 old/md/entry002.md.bak delete mode 100644 old/src/entry001/data.txt delete mode 100644 old/src/entry001/graphics.ods delete mode 100644 old/template/ebooks/svg/cover.svg delete mode 100644 old/template/ebooks/xhtml/000-cover.xhtml delete mode 100644 old/template/site/footer.html delete mode 100644 old/template/site/head.html delete mode 100644 old/template/site/header.html delete mode 100644 old/ttf/bitter-bold.ttf delete mode 100644 old/ttf/bitter-bolditalic.ttf delete mode 100644 old/ttf/bitter-italic.ttf delete mode 100644 old/ttf/bitter-regular.ttf diff --git a/README.md b/README.md new file mode 100644 index 0000000..8a35c8c --- /dev/null +++ b/README.md @@ -0,0 +1,36 @@ +# Publishing is Coding: Change My Mind + +## Donations + +🌮 Donate for some tacos with [ETH](https://etherscan.io/address/0x39b0bf0cf86776060450aba23d1a6b47f5570486). + +:dog: Donate for some dog food with [DOGE](https://dogechain.info/address/DMbxM4nPLVbzTALv5n8G16TTzK4WDUhC7G). + +:beer: Donate for some beers with [PayPal](https://www.paypal.me/perrotuerto). + +## Related links (spanish) + +Taller de Edición Digital (Digital Publishing Workshop): [ted.perrotuerto.blog](https://ted.perrotuerto.blog/). + +_Edición digital como metodología para una edición global_ (_Digital Publishing as Methodology for Global Publishing_): [ed.perrotuerto.blog](https://ed.perrotuerto.blog/). + +Pecas, herramientas editoriales (Pecas, publishing tools): [pecas.perrotuerto.blog](https://pecas.perrotuerto.blog/). + +Blog: [perrotuerto.blog](https://perrotuerto.blog). + +## License + +All content is under [Licencia Editorial Abierta y Libre (LEAL)](https://gitlab.com/NikaZhenya/licencia-editorial-abierta-y-libre). + +“Licencia Editorial Abierta y Libre” is translated to “Open and Free Publishing +License.” “LEAL” is the acronym but also means “loyal” in Spanish. + +With LEAL you are free to use, copy, reedit, modify, share or sell any of this +content under the following conditions: + +* Anything produced with this content must be under some type of LEAL. +* All files—editable or final formats—must be on public access. +* The sale can't be the only way to acquire the final product. +* The generated surplus value can't be used for exploitation of labor. +* The content can't be used for AI or data mining. +* The use of the content must not harm any collaborator. diff --git a/config/build/create-indexes-feeds b/config/build/create-indexes-feeds new file mode 100755 index 0000000..8f709fb --- /dev/null +++ b/config/build/create-indexes-feeds @@ -0,0 +1,121 @@ +#!/usr/bin/env ruby +# encoding: UTF-8 +# coding: UTF-8 + +require 'date' +require 'fileutils' +require File.realdirpath(__FILE__).gsub(/build.*$/, '') + "template/site/main_lang.rb" + +# Displays message when something goes wrong +def check condition, err_msg + if condition then puts err_msg + ' For help use -h or --help.'; abort end +end + +# To the root directory +Dir.chdir(File.dirname(__FILE__) + '/../..') + +# Variables +locale = '' +content = [] +template_dir = 'config/template/site/' + +# Displays help +if ARGV[0] =~ /-h/ + puts "create-indexes-feeds generates the index and feed file for each language." + puts "\nUse:" + puts " create-indexes-feeds" + abort +end + +# Formats date in RFC 2822 +def format_date date + raw_date = date.gsub(/[\/:]/, ',').gsub(/\s+/, '').split(',') + par_date = DateTime.new(raw_date[0].to_i, raw_date[1].to_i, raw_date[2].to_i, + raw_date[3].to_i, raw_date[4].to_i, raw_date[5].to_i, + DateTime.now.to_s[-6..-6] + DateTime.now.to_s[-4..-4]) + return par_date.rfc2822 +end + +# Itinerates each locale +Dir.glob('content/html/*').each do |local| + locale = local.split('/').last + content = [] + rss = [] + + # Gets the metadata of each post + Dir.glob(local + '/*').each do |f| + if File.basename(f) =~ /^\d+/ + file = f.split('/').last + title = File.read(f) + .gsub(/\n/, '') + .gsub(/^.*?([^<]*?)<\/title>.*$/, '\1') + .strip + date = File.read(f) + .gsub(/\n/, '') + .gsub(/^.*?#{$template_lang[locale]['build']}\s+(\d+.+?)\..*$/, '\1') + .strip + + if title != '' + content.push(' <div class="post">' + "\n" + + ' <p><a href="' + file + '">' + file.gsub(/_.*$/, '').to_i.to_s + '. ' + title + '</a></p>' + "\n" + + ' <p>[' + date + ']</p>' + "\n" + + ' </div>') + end + end + end + + # Inverse posts order from the newest to the oldest + content.reverse! + + # Creates the items for RSS feed + content.each do |c| + title = c.split('">').last.split('</a>').first + link = 'https://perrotuerto.blog/content/html/' + locale + '/' + c.split('href="').last.split('"').first + date = format_date(c.split('[').last.split(']').first) + rss.push(' <item>' + "\n" + + ' <title>' + title + '' + "\n" + + ' ' + link + '' + "\n" + + ' ' + date + '' + "\n" + + ' guid' + title.split('.')[0] + '' + "\n" + + ' ') + end + + # Cleans and adds headers and footer for index + content.unshift(File.read(template_dir + 'header.html')) + content.unshift(File.read(template_dir + 'head.html')) + content.push(File.read(template_dir + 'footer.html')) + content = content.join("\n").gsub(/\n\n/, "\n") + + # Replaces some strings for index + content = content.gsub('@file', 'index.html') + content = content.gsub('@locale', locale) + content = content.gsub('@title', $template_lang[locale]['main']) + content = content.gsub('@links', $template_lang[locale]['links']) + content = content.gsub('@about', $template_lang[locale]['about']) + content = content.gsub('@contact', $template_lang[locale]['contact']) + content = content.gsub('@fork', $template_lang[locale]['fork']) + content = content.gsub('@donate', $template_lang[locale]['donate']) + content = content.gsub('@copyfarleft', $template_lang[locale]['copyfarleft']) + content = content.gsub('@license', $template_lang[locale]['license']) + content = content.gsub('@build', $template_lang[locale]['build']) + content = content.gsub('@date', Time.now.strftime('%Y/%m/%d, %H:%M')) + + # Creates index + file = File.open(local + '/index.html', 'w:utf-8') + file.puts content + file.close + + # Cleans and add header and footer for RSS + rss.unshift(File.read(template_dir + 'head.xml')) + rss.push(File.read(template_dir + 'foot.xml')) + rss = rss.join("\n").gsub(/\n\n/, "\n") + + # Replaces some strings for RSS + rss = rss.gsub('@locale', locale) + rss = rss.gsub('@date', format_date(Time.now.strftime('%Y/%m/%d, %H:%M'))) + + # Creates RSS + file = File.open(Dir.pwd + '/feed/' + locale + '/rss.xml', 'w:utf-8') + file.puts rss + file.close +end diff --git a/config/build/pos2htmls b/config/build/pos2htmls index daa6c6f..b5a36fd 100755 --- a/config/build/pos2htmls +++ b/config/build/pos2htmls @@ -5,6 +5,7 @@ require 'simple_po_parser' require 'fileutils' require 'time' +require File.realdirpath(__FILE__).gsub(/build.*$/, '') + "template/site/main_lang.rb" # Displays message when something goes wrong def check condition, err_msg @@ -22,28 +23,6 @@ html_name = '' html_tmp = '' md_name = '' template_dir = 'config/template/site/' -template_lang = { - 'en' => { - 'links' => 'Links', - 'about' => 'About', - 'contact' => 'Contact', - 'fork' => 'Fork', - 'donate' => 'Donate', - 'copyfarleft' => 'All content is under', - 'license' => 'Open and Free Publishing License', - 'build' => 'Last build of this page:', - }, - 'es' => { - 'links' => 'Enlaces', - 'about' => 'Acerca', - 'contact' => 'Contacto', - 'fork' => 'Bifurca', - 'donate' => 'Dona', - 'copyfarleft' => 'Todo el contenido está bajo', - 'license' => 'Licencia Editorial Abierta y Libre', - 'build' => 'Última modificación de esta página:', - } -} # Displays help if ARGV[0] =~ /-h/ @@ -125,14 +104,14 @@ Dir.glob(po_dir + '*/*.po').each do |po| html_tmp = html_tmp.gsub('@locale', hash['locale']) html_tmp = html_tmp.gsub('@title', hash['title']) html_tmp = html_tmp.gsub('@file', hash['file']) - html_tmp = html_tmp.gsub('@links', template_lang[hash['locale']]['links']) - html_tmp = html_tmp.gsub('@about', template_lang[hash['locale']]['about']) - html_tmp = html_tmp.gsub('@contact', template_lang[hash['locale']]['contact']) - html_tmp = html_tmp.gsub('@fork', template_lang[hash['locale']]['fork']) - html_tmp = html_tmp.gsub('@donate', template_lang[hash['locale']]['donate']) - html_tmp = html_tmp.gsub('@copyfarleft', template_lang[hash['locale']]['copyfarleft']) - html_tmp = html_tmp.gsub('@license', template_lang[hash['locale']]['license']) - html_tmp = html_tmp.gsub('@build', template_lang[hash['locale']]['build']) + html_tmp = html_tmp.gsub('@links', $template_lang[hash['locale']]['links']) + html_tmp = html_tmp.gsub('@about', $template_lang[hash['locale']]['about']) + html_tmp = html_tmp.gsub('@contact', $template_lang[hash['locale']]['contact']) + html_tmp = html_tmp.gsub('@fork', $template_lang[hash['locale']]['fork']) + html_tmp = html_tmp.gsub('@donate', $template_lang[hash['locale']]['donate']) + html_tmp = html_tmp.gsub('@copyfarleft', $template_lang[hash['locale']]['copyfarleft']) + html_tmp = html_tmp.gsub('@license', $template_lang[hash['locale']]['license']) + html_tmp = html_tmp.gsub('@build', $template_lang[hash['locale']]['build']) html_tmp = html_tmp.gsub('@date', Time.now.strftime('%Y/%m/%d, %H:%M')) # Save the data diff --git a/config/template/site/foot.xml b/config/template/site/foot.xml new file mode 100644 index 0000000..3a9dbde --- /dev/null +++ b/config/template/site/foot.xml @@ -0,0 +1,2 @@ + + diff --git a/config/template/site/footer.html b/config/template/site/footer.html index e1a9b9d..051bced 100644 --- a/config/template/site/footer.html +++ b/config/template/site/footer.html @@ -2,7 +2,7 @@ diff --git a/config/template/site/head.xml b/config/template/site/head.xml new file mode 100644 index 0000000..06bd773 --- /dev/null +++ b/config/template/site/head.xml @@ -0,0 +1,15 @@ + + + + + Publishing is Coding: Change My Mind + https://perrotuerto.blog/content/html/@locale/ + Blog about free culture, free software and free publishing. + @locale + hi@perrotuerto.blog (Nika Zhenya) + @date + + Publishing is Coding: Change My Mind + https://perrotuerto.blog/icon.png + https://perrotuerto.blog/content/html/@locale/ + diff --git a/config/template/site/header.html b/config/template/site/header.html index ca452ee..01cdf97 100644 --- a/config/template/site/header.html +++ b/config/template/site/header.html @@ -1,6 +1,6 @@
-

Publishing is Coding: Change My Mind

+

Publishing is Coding: Change My Mind