pdf fonts
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 18 Feb 2013 15:50:12 +0000 (16:50 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Mon, 18 Feb 2013 15:50:12 +0000 (16:50 +0100)
12 files changed:
librarian/__init__.py
librarian/fonts/Dosis-Bold.ttf [new file with mode: 0644]
librarian/fonts/Dosis-ExtraBold.ttf [new file with mode: 0644]
librarian/fonts/Dosis-ExtraLight.ttf [new file with mode: 0644]
librarian/fonts/Dosis-Light.ttf [new file with mode: 0644]
librarian/fonts/Dosis-Medium.ttf [new file with mode: 0644]
librarian/fonts/Dosis-Regular.ttf [new file with mode: 0644]
librarian/fonts/Dosis-SemiBold.ttf [new file with mode: 0644]
librarian/pdf/wl.cls
librarian/pypdf.py
librarian/res/styles/edumed/logo.png [new file with mode: 0644]
librarian/res/styles/edumed/pdf/edumed.sty [new file with mode: 0755]

index 430fb7e..23244ef 100644 (file)
@@ -79,8 +79,8 @@ class WLURI(object):
     """Represents a WL URI. Extracts slug from it."""
     slug = None
 
-    example = 'http://edukacjamedialna.edu.pl/'
-    _re_wl_uri = re.compile(r'http://(www\.)?edukacjamedialna.edu.pl/(lekcje/)?'
+    example = 'http://edukacjamedialna.edu.pl/lekcje/template'
+    _re_wl_uri = re.compile(r'http://(www\.)?edukacjamedialna.edu.pl/lekcje/'
             '(?P<slug>[-a-z0-9]+)/?$')
 
     def __init__(self, uri):
@@ -101,10 +101,10 @@ class WLURI(object):
         """Contructs an URI from slug.
 
         >>> WLURI.from_slug('a-slug').uri
-        u'http://wolnelektury.pl/katalog/lektura/a-slug/'
+        u'http://edukacjamedialna.edu.pl/lekcje/a-slug/'
 
         """
-        uri = 'http://prawokultury.pl/publikacje/%s/' % slug
+        uri = 'http://edukacjamedialna.edu.pl/lekcje/%s/' % slug
         return cls(uri)
 
     def __unicode__(self):
@@ -113,6 +113,9 @@ class WLURI(object):
     def __str__(self):
         return self.uri
 
+    def canonical(self):
+        return type(self).from_slug(self.slug)
+
     def __eq__(self, other):
         return self.slug == other.slug
 
diff --git a/librarian/fonts/Dosis-Bold.ttf b/librarian/fonts/Dosis-Bold.ttf
new file mode 100644 (file)
index 0000000..d5e938e
Binary files /dev/null and b/librarian/fonts/Dosis-Bold.ttf differ
diff --git a/librarian/fonts/Dosis-ExtraBold.ttf b/librarian/fonts/Dosis-ExtraBold.ttf
new file mode 100644 (file)
index 0000000..2144a25
Binary files /dev/null and b/librarian/fonts/Dosis-ExtraBold.ttf differ
diff --git a/librarian/fonts/Dosis-ExtraLight.ttf b/librarian/fonts/Dosis-ExtraLight.ttf
new file mode 100644 (file)
index 0000000..2e3bf1b
Binary files /dev/null and b/librarian/fonts/Dosis-ExtraLight.ttf differ
diff --git a/librarian/fonts/Dosis-Light.ttf b/librarian/fonts/Dosis-Light.ttf
new file mode 100644 (file)
index 0000000..a22e7d7
Binary files /dev/null and b/librarian/fonts/Dosis-Light.ttf differ
diff --git a/librarian/fonts/Dosis-Medium.ttf b/librarian/fonts/Dosis-Medium.ttf
new file mode 100644 (file)
index 0000000..3254ef5
Binary files /dev/null and b/librarian/fonts/Dosis-Medium.ttf differ
diff --git a/librarian/fonts/Dosis-Regular.ttf b/librarian/fonts/Dosis-Regular.ttf
new file mode 100644 (file)
index 0000000..4b20862
Binary files /dev/null and b/librarian/fonts/Dosis-Regular.ttf differ
diff --git a/librarian/fonts/Dosis-SemiBold.ttf b/librarian/fonts/Dosis-SemiBold.ttf
new file mode 100644 (file)
index 0000000..5f48caf
Binary files /dev/null and b/librarian/fonts/Dosis-SemiBold.ttf differ
index fa89dc3..5a73f85 100755 (executable)
 \ifenablewlfont
 \setmainfont [
 %ExternalLocation,
-UprightFont = JunicodeWL-Regular,
-ItalicFont = JunicodeWL-Italic,
-BoldFont = JunicodeWL-Regular,
-BoldItalicFont = JunicodeWL-Italic,
-SmallCapsFont = JunicodeWL-Regular,
+UprightFont = Dosis-Regular,
+ItalicFont = Dosis-SemiBold,
+BoldFont = Dosis-Bold,
+BoldItalicFont = Dosis-Bold,
+SmallCapsFont = Dosis-Regular,
 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
 Numbers=OldStyle,
 Scale=1.04,
 LetterSpace=-1.0
-] {JunicodeWL}
+] {Dosis}
 
 \newfontfamily\alien[
 SmallCapsFeatures = {Letters={SmallCaps,UppercaseSmallCaps}},
@@ -150,7 +150,7 @@ Letters={SmallCaps,UppercaseSmallCaps}
 \fancyhf{}
 \renewcommand{\headrulewidth}{0pt}
 \renewcommand{\footrulewidth}{0pt}
-\lfoot{{\footnotesize \textsc{\@author} \emph{\@title}}}
+\lfoot{{\footnotesize \@author{} \emph{\@title}}}
 \cfoot{}
 \rfoot{{\footnotesize \thepage}}
 
@@ -406,33 +406,3 @@ Letters={Uppercase}
 }%
 \fi
 }
-
-%% EDUMED SPECIFIC
-
-\newcommand{\activitycounter}[1]{\vspace{1em}\par{\huge{#1}}}
-
-\newcommand{\activityinfo}[1]{\begin{flushright}\parbox[t]{2in}{#1}\end{flushright}}
-\newcommand{\activitytime}[1]{Czas: #1 min \\}
-\newcommand{\activityform}[1]{Forma: #1 \\}
-\newcommand{\activitytools}[1]{#1 \\}
-
-\newcommand*\checkbox{\item[\Square]}
-\newcommand*\radio{\item[\Circle]}
-
-
-\renewcommand{\naglowekrozdzial}[1]{%
-\subsection*{\typosubsection{#1}}%
-}
-
-\renewcommand{\naglowekpodrozdzial}[1]{%
-\subsubsection*{\typosubsubsection{#1}}%
-}
-
-\newcommand{\obraz}[1]{
-\includegraphics[width=8cm]{#1}
-}
-
-\newcommand{\video}[2]{
-\includegraphics[width=8cm]{#1}\\
-\href{#2}{(Otwórz wideo w serwisie YouTube)}
-}
index b56d1a6..6d6e0aa 100644 (file)
@@ -108,11 +108,15 @@ class EduModule(Xmill):
           u'</cmd>'
 
     @escape(True)
-    def get_authors(self, element):
-        authors = self.get_dc(element, 'creator.expert') + \
-          self.get_dc(element, 'creator.scenario') + \
-          self.get_dc(element, 'creator.textbook')
-        return u', '.join(authors)
+    def get_authors(self, element, which=None):
+        dc = self.options['wldoc'].book_info
+        if which is None:
+            authors = dc.authors_textbook + \
+                dc.authors_scenario + \
+                dc.authors_expert
+        else:
+            authors = getattr(dc, "authors_%s" % which)
+        return u', '.join(author.readable() for author in authors)
 
     @escape(1)
     def get_title(self, element):
@@ -133,9 +137,13 @@ class EduModule(Xmill):
             \\usepackage{morefloats}
         }{}'''),
     u'''\\def\\authors{%s}''' % self.get_authors(element),
+    u'''\\def\\authorsexpert{%s}''' % self.get_authors(element, 'expert'),
+    u'''\\def\\authorsscenario{%s}''' % self.get_authors(element, 'scenario'),
+    u'''\\def\\authorstextbook{%s}''' % self.get_authors(element, 'textbook'),
+    
     u'''\\author{\\authors}''',
     u'''\\title{%s}''' % self.get_title(element),
-    u'''\\def\\bookurl{%s}''' % self.get_dc(element, 'identifier.url', True),
+    u'''\\def\\bookurl{%s}''' % self.options['wldoc'].book_info.url.canonical(),
     u'''\\def\\rightsinfo{%s}''' % self.get_rightsinfo(element),
     u'</TeXML>']
 
@@ -147,7 +155,7 @@ class EduModule(Xmill):
         return u"""
     <env name="document">
     <cmd name="maketitle"/>
-    """, """</env>"""
+    """, """<cmd name="editorialsection" /></env>"""
 
     @escape(1)
     def handle_texcommand(self, element):
@@ -231,7 +239,7 @@ class EduModule(Xmill):
         counter = self.activity_counter
 
         return u"""
-
+<cmd name="noindent" />
 <cmd name="activitycounter"><parm>%(counter)d.</parm></cmd>
 <cmd name="activityinfo"><parm>
  <cmd name="activitytime"><parm>%(czas)s</parm></cmd>
@@ -269,7 +277,7 @@ class EduModule(Xmill):
                 surl = 'http://edukacjamedialna.edu.pl/slowniczek'
             sxml = None
             if surl:
-                sxml = etree.fromstring(self.options['provider'].by_uri(surl).get_string())
+                sxml = etree.fromstring(self.options['wldoc'].provider.by_uri(surl).get_string())
             self.options = {'slowniczek': True, 'slowniczek_xml': sxml }
 
         listcmd = {'num': 'enumerate',
@@ -361,7 +369,7 @@ class EduModule(Xmill):
             else:
                 return cmd('href', parms=[element.attrib['url']])(self, element)
         else:
-            return cmd('em')(self, element)
+            return cmd('emph')(self, element)
 
     def handle_obraz(self, element):
         frmt = self.options['format']
@@ -583,10 +591,12 @@ def fix_lists(tree):
 
 
 class EduModulePDFFormat(PDFFormat):
+    style = get_resource('res/styles/edumed/pdf/edumed.sty')
+
     def get_texml(self):
         self.attachments = {}
         edumod = EduModule({
-            'provider': self.wldoc.provider, 
+            "wldoc": self.wldoc,
             "format": self,
             "teacher": self.customization.get('teacher'),
         })
@@ -597,6 +607,7 @@ class EduModulePDFFormat(PDFFormat):
 
     def get_tex_dir(self):
         temp = super(EduModulePDFFormat, self).get_tex_dir()
+        shutil.copy(get_resource('res/styles/edumed/logo.png'), temp)
         for name, iofile in self.attachments.items():
             iofile.save_as(os.path.join(temp, name))
         return temp
diff --git a/librarian/res/styles/edumed/logo.png b/librarian/res/styles/edumed/logo.png
new file mode 100644 (file)
index 0000000..eab7eed
Binary files /dev/null and b/librarian/res/styles/edumed/logo.png differ
diff --git a/librarian/res/styles/edumed/pdf/edumed.sty b/librarian/res/styles/edumed/pdf/edumed.sty
new file mode 100755 (executable)
index 0000000..a936ef7
--- /dev/null
@@ -0,0 +1,77 @@
+
+\newcommand{\activitycounter}[1]{\vspace{1em}\par{\huge{#1}}}
+
+\newcommand{\activityinfo}[1]{\begin{flushright}\parbox[t]{2in}{#1}\end{flushright}}
+\newcommand{\activitytime}[1]{Czas: #1 min \\}
+\newcommand{\activityform}[1]{Forma: #1 \\}
+\newcommand{\activitytools}[1]{#1 \\}
+
+\newcommand*\checkbox{\item[\Square]}
+\newcommand*\radio{\item[\Circle]}
+
+
+\renewcommand{\naglowekrozdzial}[1]{%
+\subsection*{\typosubsection{#1}}%
+}
+
+\renewcommand{\naglowekpodrozdzial}[1]{%
+\subsubsection*{\typosubsubsection{#1}}%
+}
+
+\newcommand{\obraz}[1]{
+\includegraphics[width=8cm]{#1}
+}
+
+\newcommand{\video}[2]{
+\includegraphics[width=8cm]{#1}\\
+\href{#2}{(Otwórz wideo w serwisie YouTube)}
+}
+
+\renewcommand{\maketitle}{
+    {
+    \thispagestyle{empty}
+    \footnotesize
+    \color{theme}
+
+    \noindent \begin{minipage}[t]{.35\textwidth}\vspace{0pt}
+        \href{http://edukacjamedialna.edu.pl}{\xbox{\includegraphics[width=\textwidth]{logo.png}}}
+    \end{minipage}
+
+    \vspace{.6em}
+    \color{black}
+    }
+}
+
+\newcommand{\rightsinfostr}[2][] {
+    \ifx&#1&%
+        #2
+    \else
+        Udostępniono na licencji \href{#1}{#2}.
+    \fi
+}
+
+\newcommand{\editorialsection}{
+  \begin{figure}[b!]
+  {
+    \footnotesize
+    \color{theme}
+    \noindent \rule{\linewidth}{0.4pt}
+
+    \rightsinfo
+    \vspace{.6em}
+
+
+Tekst: \authorstextbook, scenariusz: \authorsscenario, konsultacja merytoryczna: \authorsexpert.
+Materiał pochodzi z serwisu \href{http://edukacjamedialna.edu.pl}{edukacjamedialna.edu.pl} prowadzonego przez 
+\href{http://nowoczesnapolska.org.pl}{Fundację Nowoczesna Polska}.
+
+\vspace{.6em}
+\rightsinfo
+
+\vspace{.6em}
+Źródło: \href{\bookurl}{\bookurl}.
+
+    \color{black}
+  }
+  \end{figure}
+}