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