Prueba RSS
This commit is contained in:
parent
b9aeaa7142
commit
b7d541e50b
|
@ -0,0 +1,154 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# encoding: UTF-8
|
||||||
|
# coding: UTF-8
|
||||||
|
|
||||||
|
require 'fileutils'
|
||||||
|
require 'time'
|
||||||
|
require 'json'
|
||||||
|
|
||||||
|
Encoding.default_internal = Encoding::UTF_8
|
||||||
|
Dir.chdir(File.dirname(__FILE__))
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
$language = 'en-US'
|
||||||
|
$site_name = 'Publishing is Coding: Change My Mind'
|
||||||
|
$site_description = 'A broken english version of some entries published in Mariana Eguaras\'s blog.'
|
||||||
|
$site_keywords = 'publishing, blog, book, ebook, methodology, foss, libre-software, format, markdown, html, epub, pdf, mobi, latex, tex'
|
||||||
|
$site_link = 'https://blog.cliteratu.re'
|
||||||
|
$site_img = 'icon.png'
|
||||||
|
$author_name = 'Nika Zhenya'
|
||||||
|
$author_email = 'nika.zhenya@cliteratu.re'
|
||||||
|
$date = Time.now.to_s.split(' ')[0]
|
||||||
|
$rss = {
|
||||||
|
:channel => {
|
||||||
|
:title => $site_name,
|
||||||
|
:link => $site_link,
|
||||||
|
:description => $site_description,
|
||||||
|
:language => $language,
|
||||||
|
:managingEditor => $author_email + ' (' + $author_name + ')',
|
||||||
|
:lastBuildDate => '',
|
||||||
|
:image => {
|
||||||
|
:title => $site_name,
|
||||||
|
:url => $site_link + '/' + $site_img,
|
||||||
|
:link => $site_link
|
||||||
|
},
|
||||||
|
:items => []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Definitions
|
||||||
|
|
||||||
|
# Gets date in a proper format
|
||||||
|
def get_date d, rfc = false
|
||||||
|
d = d.split('-')
|
||||||
|
|
||||||
|
def month m
|
||||||
|
months = [
|
||||||
|
'January', 'February', 'March', 'April',
|
||||||
|
'May', 'June', 'July', 'August',
|
||||||
|
'September', 'October', 'November', 'December'
|
||||||
|
]
|
||||||
|
|
||||||
|
return months[m.to_i - 1]
|
||||||
|
end
|
||||||
|
|
||||||
|
if rfc
|
||||||
|
return Time.new(d[0], d[1], d[2]).rfc2822
|
||||||
|
else
|
||||||
|
return month(d[1]) + ' ' +
|
||||||
|
d[2].to_i.to_s + ', ' +
|
||||||
|
d[0]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Converts MD in other formats
|
||||||
|
def convert_md md
|
||||||
|
content = []
|
||||||
|
original = {:link => '', :pubDate => ''}
|
||||||
|
item = {
|
||||||
|
:guid => $site_link + '/html/' + File.basename(md, '.*'),
|
||||||
|
:title => '',
|
||||||
|
:link => $site_link + '/html/' + File.basename(md, '.*') + '.html',
|
||||||
|
:description => '',
|
||||||
|
:author => $author_email + ' (' + $author_name + ')',
|
||||||
|
:category => '',
|
||||||
|
:pubDate => ''
|
||||||
|
}
|
||||||
|
|
||||||
|
def item_split s
|
||||||
|
return s.gsub(/@\S+\['(.*?)'\]/, '\1').strip.split('\',\'')
|
||||||
|
end
|
||||||
|
|
||||||
|
file = File.open(md, 'r:UTF-8')
|
||||||
|
file.each_with_index do |l, i|
|
||||||
|
if i == 0
|
||||||
|
item[:title] = l.gsub(/^#/, '').strip
|
||||||
|
end
|
||||||
|
|
||||||
|
if l =~ /^@original\[.*?\]\s*?$/
|
||||||
|
data = item_split(l)
|
||||||
|
content.push(
|
||||||
|
'<p class="original">Spanish: ' +
|
||||||
|
get_date(data[0]) + ' | ' +
|
||||||
|
'<a target="_blank" href="' + data[1] + '">' +
|
||||||
|
'source</a></p>'
|
||||||
|
)
|
||||||
|
elsif l =~ /^@current\[.*?\]\s*?$/
|
||||||
|
data = item_split(l)
|
||||||
|
item[:pubDate] = get_date(data[0], true)
|
||||||
|
item[:category] = data[1]
|
||||||
|
item[:description] = data[2]
|
||||||
|
content.push(
|
||||||
|
'<p class="current">English: ' +
|
||||||
|
get_date(data[0]) + ' | ' +
|
||||||
|
data[1] + '</p>'
|
||||||
|
)
|
||||||
|
else
|
||||||
|
content.push(l)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
$rss[:channel][:items].push(item)
|
||||||
|
end
|
||||||
|
|
||||||
|
# Converts the RSS to a XML syntax
|
||||||
|
def convert_xml file, hash, space = ''
|
||||||
|
hash.each do |k, v|
|
||||||
|
if k.to_s != 'items'
|
||||||
|
file.puts space + '<' + k.to_s + '>'
|
||||||
|
end
|
||||||
|
|
||||||
|
if v.class == Hash
|
||||||
|
convert_xml(file, v, space + ' ')
|
||||||
|
elsif v.class == Array
|
||||||
|
v.each do |e|
|
||||||
|
file.puts space + '<item>'
|
||||||
|
convert_xml(file, e, space + ' ')
|
||||||
|
file.puts space + '</item>'
|
||||||
|
end
|
||||||
|
else
|
||||||
|
file.puts space + ' ' + v
|
||||||
|
end
|
||||||
|
|
||||||
|
if k.to_s != 'items'
|
||||||
|
file.puts space + '</' + k.to_s + '>'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Deployment
|
||||||
|
|
||||||
|
# Gets MDs to convert in other formats
|
||||||
|
Dir.glob('md/*.{md}').each_with_index do |md, i|
|
||||||
|
convert_md(File.absolute_path(md))
|
||||||
|
end
|
||||||
|
|
||||||
|
# Builds the RSS
|
||||||
|
$rss[:channel][:lastBuildDate] = get_date($date, true)
|
||||||
|
$rss[:channel][:items].sort_by!{|h| h[:link]}.reverse!
|
||||||
|
xml = File.new('feed/rss.xml', 'w:UTF-8')
|
||||||
|
xml.puts '<?xml version="1.0" ?>'
|
||||||
|
xml.puts '<rss version="2.0">'
|
||||||
|
convert_xml(xml, $rss)
|
||||||
|
xml.puts '</rss>'
|
||||||
|
xml.close
|
|
@ -0,0 +1,8 @@
|
||||||
|
.addenda {
|
||||||
|
border-left: 3px solid yellow;
|
||||||
|
padding-left: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.original {}
|
||||||
|
|
||||||
|
.current {}
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
|
<rss version="2.0">
|
||||||
|
<channel>
|
||||||
|
<title>
|
||||||
|
Publishing is Coding: Change My Mind
|
||||||
|
</title>
|
||||||
|
<link>
|
||||||
|
https://blog.cliteratu.re
|
||||||
|
</link>
|
||||||
|
<description>
|
||||||
|
A broken english version of some entries published in Mariana Eguaras's blog.
|
||||||
|
</description>
|
||||||
|
<language>
|
||||||
|
en-US
|
||||||
|
</language>
|
||||||
|
<managingEditor>
|
||||||
|
nika.zhenya@cliteratu.re (Nika Zhenya)
|
||||||
|
</managingEditor>
|
||||||
|
<lastBuildDate>
|
||||||
|
Wed, 03 Oct 2018 00:00:00 -0500
|
||||||
|
</lastBuildDate>
|
||||||
|
<image>
|
||||||
|
<title>
|
||||||
|
Publishing is Coding: Change My Mind
|
||||||
|
</title>
|
||||||
|
<url>
|
||||||
|
https://blog.cliteratu.re/icon.png
|
||||||
|
</url>
|
||||||
|
<link>
|
||||||
|
https://blog.cliteratu.re
|
||||||
|
</link>
|
||||||
|
</image>
|
||||||
|
<item>
|
||||||
|
<guid>
|
||||||
|
https://blog.cliteratu.re/html/entry001
|
||||||
|
</guid>
|
||||||
|
<title>
|
||||||
|
Digital Publishing as Publishing from Scratch
|
||||||
|
</title>
|
||||||
|
<link>
|
||||||
|
https://blog.cliteratu.re/html/entry001.html
|
||||||
|
</link>
|
||||||
|
<description>
|
||||||
|
A general comparation between the most common methods for developing EPUBs.
|
||||||
|
</description>
|
||||||
|
<author>
|
||||||
|
nika.zhenya@cliteratu.re (Nika Zhenya)
|
||||||
|
</author>
|
||||||
|
<category>
|
||||||
|
Methodology
|
||||||
|
</category>
|
||||||
|
<pubDate>
|
||||||
|
Wed, 03 Oct 2018 00:00:00 -0500
|
||||||
|
</pubDate>
|
||||||
|
</item>
|
||||||
|
</channel>
|
||||||
|
</rss>
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Digital Publishing as Publishing from Scratch
|
||||||
|
|
||||||
|
@original['2016-09-06','https://marianaeguaras.com/edicion-digital-como-edicion-desde-cero']
|
||||||
|
@current['2018-10-03','Methodology','A general comparation between the most common methods for developing EPUBs.']
|
||||||
|
|
||||||
|
Thanks to [Mariana Eguaras](http://marianaeguaras.com/)
|
||||||
|
we are going to blogging about __digital publishing__,
|
||||||
|
its __characteristics, benefits and challenges__, as
|
||||||
|
well as __its relation with print publishing__ and how
|
||||||
|
these issues directly affect the necesary proceedings
|
||||||
|
for any kind of publishing.
|
||||||
|
|
||||||
|
We already have planned what we are going write in the
|
||||||
|
first entries, but any suggestion is welcome. As far as
|
||||||
|
possible the writing is not going to be technical and
|
||||||
|
more friendly to general public or publishers.
|
||||||
|
|
||||||
|
However, you have to consider that some technicalities
|
||||||
|
are now necessary for publishing. As well as the
|
||||||
|
typography, printing or design slangs are common
|
||||||
|
knowledge for publishers, in the same way the jargons
|
||||||
|
from web or software developers are starting to be part
|
||||||
|
of our cultural background.
|
||||||
|
|
||||||
|
> As you can see, the entries were originally wrote
|
||||||
|
> in spanish. And as you can realize, some of them are
|
||||||
|
> now kind of old: for some things I already have a
|
||||||
|
> different opinion or distinct approach. And as is
|
||||||
|
> obvious, english is not my first language. Therefore,
|
||||||
|
> you are going to find a lot of grammar mistakes or
|
||||||
|
> typos and I will only translate (in a very free way)
|
||||||
|
> the entries that I still consider relevant. So when
|
||||||
|
> you find this kind of box, it means that it is an
|
||||||
|
> _addendum_ for this broken english version. {addenda}
|
||||||
|
|
||||||
|
> Do you want to improve this mess? You can always help
|
||||||
|
> through GitLab or GitHub. Please see the footer for
|
||||||
|
> more info. {addenda}
|
|
@ -0,0 +1,16 @@
|
||||||
|
<footer>
|
||||||
|
<p class="centered">Last build: $date$</p>
|
||||||
|
<p class="centered vertical-space1">All content is under <a target="_blank" href="https://github.com/NikaZhenya/licencia-editorial-abierta-y-libre">Licencia Editorial Abierta y Libre (<span class="smallcap">LEAL</span>)</a>.</p>
|
||||||
|
<p class="centered">“Licencia Editorial Abierta y Libre” is translated to “Open and Free Publishing License”. “<span class="smallcap">LEAL</span>” is the acronym but also means “loyal” in spanish.</p>
|
||||||
|
<p class="centered">With <span class="smallcap">LEAL</span> you are free to use, copy, reedit, modify, distribute or merchandise any of this content under the following conditions:</p>
|
||||||
|
<ol>
|
||||||
|
<li><p>Any product produced with this content must be under some type of <span class="smallcap">LEAL</span>.</p></li>
|
||||||
|
<li><p>Merchandising cannot be the only way to acquire the final product.</p></li>
|
||||||
|
<li><p>The use of content mustn't harm to any collaborator.</p></li>
|
||||||
|
<li><p>All files (editables or finals) must be public access.</p></li>
|
||||||
|
</ol>
|
||||||
|
<p class="centered vertical-space1">Taller de Edición Digital (Digital Publishing Workshop): <a target="_blank" href="https://ted.cliteratu.re/">ted.cliteratu.re</a>.</p>
|
||||||
|
<p class="centered">_Edición digital como metodología para una edición global_ (_Digital Publishing as Methodology for Global Publishing_): <a target="_blank" href="https://ed.cliteratu.re/">ed.cliteratu.re</a>.</p>
|
||||||
|
<p class="centered">Pecas, herramientas editoriales (Pecas, publishing tools): <a target="_blank" href="https://pecas.cliteratu.re/">pecas.cliteratu.re</a>.</p>
|
||||||
|
<p class="centered">Sitio personal (personal website): <a target="_blank" href="https://xxx.cliteratu.re/">xxx.cliteratu.re</a>.</p>
|
||||||
|
</footer>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<head>
|
||||||
|
<title>$site_name$ | $title$</title>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="application-name" content="$site_name$">
|
||||||
|
<meta name="description" content="$site_description$">
|
||||||
|
<meta name="keywords" content="$site_keywords$">
|
||||||
|
<link rel="shortcut icon" href="$site_img$">
|
||||||
|
<link rel="alternate" type="application/rss+xml" href="$site_link$/feed/" title="$site_name$">
|
||||||
|
<link type="text/css" rel="stylesheet" href="../css/styles.css">
|
||||||
|
</head>
|
|
@ -0,0 +1,22 @@
|
||||||
|
<header>
|
||||||
|
<h1><a href="$site_link$">$site_name$</a></h1>
|
||||||
|
<p>$site_description$</p>
|
||||||
|
<nav>
|
||||||
|
<h3>Repos</h3>
|
||||||
|
<p><a target="_blank" href="https://gitlab.com/NikaZhenya/publishing-is-coding">GitLab</a></p>
|
||||||
|
<p><a target="_blank" href="https://github.com/NikaZhenya/publishing-is-coding">GitHub</a></p>
|
||||||
|
<p><a target="_blank" href="http://git.cliteratu.re/publishing-is-coding">GitList</a></p>
|
||||||
|
</nav>
|
||||||
|
<nav class="vertical-space1">
|
||||||
|
<h3>Contact</h3>
|
||||||
|
<p><a target="_blank" href="mailto:nika.zhenya@cliteratu.re">Email</a></p>
|
||||||
|
<p><a target="_blank" href="https://mastodon.social/@_perroTuerto">Mastodon.social</a></p>
|
||||||
|
<p><a target="_blank" href="https://twitter.com/_perroTuerto">Twitter</a></p>
|
||||||
|
</nav>
|
||||||
|
<nav class="vertical-space1">
|
||||||
|
<h3>Donations</h3>
|
||||||
|
<p><a target="_blank" href="https://etherscan.io/address/0x39b0bf0cf86776060450aba23d1a6b47f5570486"><span class="smallcap">ETH</span></a></p>
|
||||||
|
<p><a target="_blank" href="https://dogechain.info/address/DMbxM4nPLVbzTALv5n8G16TTzK4WDUhC7G"><span class="smallcap">DOGE</span></a></p>
|
||||||
|
<p><a target="_blank" href="https://www.paypal.me/perrotuerto">PayPal</a></p>
|
||||||
|
</nav>
|
||||||
|
</header>
|
Loading…
Reference in New Issue