Permalink
Browse files

esquelet de la documentació pel curs de moose

  • Loading branch information...
0 parents commit 78dd49a4bb8e28571358c9c2a7b36d5ac662a13f @alexm committed Mar 8, 2012
Showing with 809 additions and 0 deletions.
  1. +15 −0 .gitignore
  2. +26 −0 README
  3. +160 −0 Rakefile
  4. +4 −0 ca/02-moose/01-intro.markdown
  5. +9 −0 ca/02-moose/02-moose.markdown
  6. 0 ebooks/cover.png
  7. +28 −0 epub/moose.css
  8. 0 epub/title.png
  9. +90 −0 epub/title.svg
  10. +11 −0 latex/README
  11. +23 −0 latex/config.yml
  12. +178 −0 latex/makepdf
  13. +158 −0 latex/template.tex
  14. +52 −0 makeebooks
  15. +26 −0 makepdfs
  16. +29 −0 summary.rb
@@ -0,0 +1,15 @@
+moose.*.pdf
+moose.*.mobi
+moose.*.epub
+moose.*.html
+moose.*.epub
+*.swp
+latex/*
+!latex/makepdf
+!latex/README
+!latex/template.tex
+!latex/config.yml
+epub/temp
+*~
+.#*
+figures/*
26 README
@@ -0,0 +1,26 @@
+Documentació del Curs de Perl: Moose
+====================================
+
+Aquest projecte és el codi de la documentació del tema
+sobre orientació a objectes amb Moose del Curs de Perl
+dels Perl Mongers de Barcelona (http://barcelona.pm).
+
+Requeriments
+------------
+
+ $ sudo apt-get install calibre pandoc \
+ ruby rubygems ruby-dev \
+ texlive-xetex texlive-latex-recommended
+ $ gem install --user-install ruby-debug rdiscount maruku
+ $ ./makepdfs
+
+Llicència
+---------
+
+Els fonts de la documentació d'aquest projecte es troben
+sota del directori amb el codi d'idioma (e.g. `ca`) i estan
+disponibles sota la mateixa llicència de Perl. La resta
+dels continguts deriven del codi per al fantàstic llibre
+___Pro Git___ d'en Scott Chacon, estan disponibles sota la
+llicència cc-by-nc-sa 3.0 (https://github.com/progit/progit).
+
160 Rakefile
@@ -0,0 +1,160 @@
+# encoding: UTF-8
+
+require 'rake/clean'
+
+
+$lang = ENV['language']
+$lang ||= 'en'
+
+namespace :epub do
+ TMP_DIR = File.join('epub', 'temp', $lang)
+ INDEX_FILEPATH = File.join(TMP_DIR, 'moose.html')
+ TARGET_FILEPATH = "moose-#{$lang}.epub"
+
+ SOURCE_FILES = FileList.new(File.join($lang, '**', '*.markdown')).sort
+ CONVERTED_MK_FILES = SOURCE_FILES.pathmap(File.join(TMP_DIR, '%f'))
+ HTML_FILES = CONVERTED_MK_FILES.ext('html')
+
+ desc "generate EPUB ebook (add language=xx to build lang xx)"
+ task :generate => :check
+ task :generate => TARGET_FILEPATH
+
+ desc "check whether all the required tools are installed"
+ task :check do
+ begin
+ require 'maruku'
+ found_maruku = true
+ rescue LoadError
+ found_maruku = false
+ end
+
+ $ebook_convert_cmd = ENV['ebook_convert_path'].to_s
+ if $ebook_convert_cmd.empty?
+ $ebook_convert_cmd = `which ebook-convert`.chomp
+ end
+ if $ebook_convert_cmd.empty?
+ mac_osx_path = '/Applications/calibre.app/Contents/MacOS/ebook-convert'
+ $ebook_convert_cmd = mac_osx_path
+ end
+ found_calibre = File.executable?($ebook_convert_cmd)
+
+ if !found_maruku
+ puts 'EPUB generation requires the Maruku gem.'
+ puts ' On Ubuntu call "sudo apt-get install libmaruku-ruby".'
+ end
+ if !found_calibre
+ puts 'EPUB generation requires Calibre.'
+ puts ' On Ubuntu call "sudo apt-get install calibre".'
+ end
+
+ if !found_calibre || !found_maruku then exit 1 end
+ end
+
+ directory TMP_DIR
+
+ rule '.html' => '.mk' do |t|
+ require 'maruku'
+
+ mk_filename = t.source
+ html_filename = t.name
+ puts "Converting #{mk_filename} -> #{html_filename}"
+
+ mk_file = File.open(mk_filename, 'r') do |mk|
+ html_file = File.open(html_filename, 'w') do |html|
+ code = Maruku.new(mk.read.encode("UTF-8")).to_html
+ code.gsub!(/^(<h.) (id='[^']+?')/, '\1')
+ html << code
+ html << "\n"
+ end
+ end
+ end
+
+ src_for_converted = proc do |dst|
+ base_name = dst.pathmap('%n')
+ SOURCE_FILES.find { |s| s.pathmap('%n') == base_name }
+ end
+
+ rule '.mk' => src_for_converted do |t|
+ src_filename = t.source
+ dest_filename = t.name
+ puts "Processing #{src_filename} -> #{dest_filename}"
+
+ figures_dir = "../../../figures"
+
+ dest_file = File.open(dest_filename, 'w')
+ src_file = File.open(src_filename, 'r')
+ until src_file.eof?
+ line = src_file.readline
+
+ matches = line.match /^\s*Insereix\s(.*)/
+ if matches
+ image_path = matches[1]
+ real_image_path = image_path.pathmap("#{figures_dir}/%X-tn%x")
+
+ next_line = src_file.readline.chomp
+
+ line = "![#{next_line}](#{real_image_path} \"#{next_line}\")\n"
+ end
+
+ dest_file << line
+ end
+ src_file.close
+ dest_file.close
+ end
+
+ file INDEX_FILEPATH => TMP_DIR
+ file INDEX_FILEPATH => HTML_FILES do
+ index_file = File.open(INDEX_FILEPATH, 'w') do |file|
+ file << '<?xml version="1.0" encoding="UTF-8"?>'
+ file << "\n"
+ file << '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" '
+ file << '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'
+ file << "\n"
+ file << "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='#{$lang}'>"
+ file << '<head>'
+ file << '<title>Curs de Perl: Moose</title>'
+ file << '</head>'
+ file << '<body>'
+ file << "\n"
+
+ HTML_FILES.each do |chapter_file|
+ file << File.open(chapter_file).read
+ file << "\n"
+ end
+
+ file << '</body></html>'
+ file << "\n"
+ end
+ end
+
+ file TARGET_FILEPATH => INDEX_FILEPATH do
+ opts = [
+ '--language', $lang,
+ '--authors', 'Alex Muntada',
+ '--comments', 'Curs de Perl: Moose',
+
+ '--cover', 'epub/title.png',
+ '--extra-css', 'epub/moose.css',
+
+ '--chapter', '//h:h1',
+ '--level1-toc', '//h:h1',
+ '--level2-toc', '//h:h2',
+ '--level3-toc', '//h:h3',
+ ]
+
+ sh $ebook_convert_cmd, INDEX_FILEPATH, TARGET_FILEPATH, *opts
+ end
+
+ CLEAN.push(*CONVERTED_MK_FILES)
+ CLEAN.push(*HTML_FILES)
+ CLEAN << INDEX_FILEPATH
+ CLEAN << TMP_DIR
+ CLOBBER << TARGET_FILEPATH
+end
+
+namespace :pdf do
+ desc "generate a pdf"
+ task :generate do
+ system("ruby makepdfs")
+ end
+end
@@ -0,0 +1,4 @@
+# Sistema d'objectes de Perl 5 #
+## Mòduls ##
+## Classes, mètodes i atributs ##
+## Herència ##
@@ -0,0 +1,9 @@
+# Moose #
+## Introducció ##
+## Modificadors de mètodes ##
+## Subtipus i coercions ##
+## Rols i trets ##
+## Delegació ##
+## Constructors i destructors ##
+## Protocol de meta-objectes i immutabilitat ##
+## Extensions de Moose ##
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,28 @@
+ul {
+ margin: 20px;
+}
+
+ol {
+ margin: 20px;
+}
+
+body pre {
+ margin: 10px;
+ font-weight: bold;
+}
+
+body pre2 {
+ background-color: silver;
+ padding: 10px;
+ border-top-style: solid;
+ border-left-style: solid;
+ border-left-width: 1px;
+ border-top-width: 1px;
+ overflow-x: auto; /* Use horizontal scroller if needed; for Firefox 2, not needed in Firefox 3 */
+ white-space: pre-wrap; /* css-3 */
+ white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
+ white-space: -pre-wrap; /* Opera 4-6 */
+ white-space: -o-pre-wrap; /* Opera 7 */
+ /* width: 99%; */
+ word-wrap: break-word; /* Internet Explorer 5.5+ */
+ }
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="744.09448819"
+ height="1052.3622047"
+ id="svg2"
+ version="1.1"
+ inkscape:version="0.48.0 r9654"
+ sodipodi:docname="title.svg"
+ inkscape:export-filename="/home/alexm/git/cursperl-moose/epub/title.png"
+ inkscape:export-xdpi="90"
+ inkscape:export-ydpi="90">
+ <defs
+ id="defs4" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="0.69977474"
+ inkscape:cx="380.35888"
+ inkscape:cy="530.9118"
+ inkscape:document-units="px"
+ inkscape:current-layer="capa1"
+ showgrid="false"
+ inkscape:window-width="1128"
+ inkscape:window-height="938"
+ inkscape:window-x="249"
+ inkscape:window-y="31"
+ inkscape:window-maximized="0" />
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Capa 1"
+ inkscape:groupmode="layer"
+ id="capa1">
+ <rect
+ style="fill:#cccccc"
+ id="rect2985"
+ width="600"
+ height="800"
+ x="70.02253"
+ y="105.17196" />
+ <text
+ xml:space="preserve"
+ style="font-size:48px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans"
+ x="366.35913"
+ y="420.73035"
+ id="text2987"
+ sodipodi:linespacing="125%"><tspan
+ sodipodi:role="line"
+ x="366.35913"
+ y="420.73035"
+ id="tspan2991">Curs de Perl</tspan><tspan
+ sodipodi:role="line"
+ x="366.35913"
+ y="468.76935"
+ id="tspan2999"
+ style="font-size:36px;text-align:center;text-anchor:middle">Moose</tspan><tspan
+ sodipodi:role="line"
+ x="366.35913"
+ y="513.76935"
+ id="tspan2995" /><tspan
+ sodipodi:role="line"
+ x="366.35913"
+ y="558.76935"
+ id="tspan3003"
+ style="font-size:36px;text-align:center;text-anchor:middle">Alex Muntada</tspan></text>
+ </g>
+</svg>
@@ -0,0 +1,11 @@
+Versió en PDF
+=============
+
+Per a obtenir una versió PDF en català executeu `makepdf ca` i un fitxer
+`moose.ca.pdf` apareixerà a l'arrel del projecte.
+
+* `config.yml`: és un fitxer de configuració senzill per a personalitzar
+ el document generat.
+* `template.tex`: és el fitxer LaTeX principal, que determina l'estil de
+ la versió PDF del document. Es tracta d'una plantilla ERB que inclou les
+ personalitzacions de config.yml.
@@ -0,0 +1,23 @@
+default:
+ babel: "catalan"
+ langrule: ""
+ font: Ubuntu
+ bold: "{* Bold}"
+ mono: Inconsolata
+ prechap: "Capítol "
+ postchap: ""
+ presect: "Secció "
+ postsect: ""
+ dql: "«"
+ dqr: "»"
+ con: "Índex"
+ fig: "Figura "
+ tab: "Taula "
+ indent: "\\qquad"
+ title: "Curs de Perl"
+ subtitle: "Moose"
+ comment: "(Orientació a Objectes)"
+ author: "Alex Muntada"
+ co-author: "<alexm@alexm.org>"
+ thanks: "\\emph{use Perl;}"
+ abstract: ""
Oops, something went wrong.

0 comments on commit 78dd49a

Please sign in to comment.