Skip to content

Commit 9c0150e

Browse files
committed
documented pdf view
1 parent 85a5df3 commit 9c0150e

File tree

3 files changed

+103
-20
lines changed

3 files changed

+103
-20
lines changed

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Django-Vitae is developed and tested in Python 3. It depends on several external
2121
* `Markdown <https://pypi.org/project/Markdown/>`_ (makes pretty HTML with simple text entries)
2222
* `citeproc-py <https://pypi.org/project/citeproc-py/>`_ (creates citations formatted according to desired `CSL`_ styles [not yet implemented])
2323
* `citeproc-py-styles <https://pypi.org/project/citeproc-py-styles/>`_ (adds library of `CSL`_ styles)
24+
* `reportlab <https://www.reportlab.com/>`_ (creates PDFs on-the-fly)
2425

2526
.. _CSL: http://citationstyles.org/
2627

docs/source/index.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ If you do not have experience with Django_, you might be interested in the :ref:
3939
Organization of the Documentation
4040
---------------------------------
4141

42+
* :doc:`Complete Vitae Views <views/index>`
43+
44+
* :ref:`HTML <views-html>`
45+
* :ref:`PDF <views-pdf>`
46+
4247
* :doc:`CV Sections <topics/index>` documents the API to write lines on CV by
4348
different sections on a CV
4449

@@ -60,11 +65,6 @@ Organization of the Documentation
6065

6166
* Service
6267

63-
* :doc:`Views <views/index>`
64-
65-
* :ref:`HTML <views-html>`
66-
* :ref:`PDF <views-pdf>`
67-
6868
* Templates
6969

7070
* Template tags & filters
@@ -102,8 +102,8 @@ Documentation Contents
102102
:name: fronttoc
103103

104104
getting_started
105-
topics/index
106105
views/index
106+
topics/index
107107
shortcuts
108108
settings
109109
reference/index

docs/source/views/index.rst

Lines changed: 96 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
Views
2-
=====
1+
Complete Vitae Views
2+
====================
33

44
.. toctree::
55
:name: viewstoc
@@ -8,17 +8,18 @@ Views
88

99
.. _views-html:
1010

11-
Django Vitae provides two primary views for a CV: HTML and PDF.
11+
Django Vitae provides two primary views that represent the entire CV
12+
document: HTML and PDF.
1213

1314
HTML
1415
^^^^
1516

16-
The primary view provided by Django Vitae represents CVs as webpages. This is the view made available at the application's root URL, that is ``/``. The URL retrieves the view :class:`cv.views.CVView` that gathers the data from individual models and presents them in appropriate sections.
17+
The primary view provided by Django Vitae represents a CV as a webpage.
18+
This is the view made available at the application's root URL, that is
19+
``/``. The URL retrieves the view :class:`cv.views.CVView` that gathers
20+
the data from individual models and presents them in appropriate sections.
1721

18-
Template Structure
19-
~~~~~~~~~~~~~~~~~~
20-
21-
Template structure::
22+
**Template Structure**::
2223

2324
cv/
2425
sections/
@@ -28,18 +29,99 @@ Template structure::
2829
skeleton.html
2930

3031

31-
The HTML views use a series of templates. At the lowest level, ``cv/skeleton.html`` defines the main structure for the page. The default template uses `Bootstrap`_ CSS styles and JavaScript and `Font Awesome`_ icons from their respective CDNs.
32+
The HTML views use a series of templates layered on top of one
33+
another. At the lowest level, ``cv/skeleton.html`` **defines the
34+
main structure for the page**. The default template uses CSS styles
35+
and Javascript from `Bootstrap` and icons from `Font Awesome`_
36+
icons, using their respective `CDNs`_.
3237

3338
.. _Bootstrap: https://getbootstrap.com/
3439
.. _Font Awesome: https://fontawesome.com/
35-
36-
The next template, ``cv/base.html`` inherits from ``cv/skeleton.html`` and **defines the order of sections** as a series of Django template blocks. The template ``cv/cv.html`` inherits from the ``cv/base.html`` template and defines each section.
37-
38-
In the default templates included with Django Vitae, ``cv/cv.html`` wraps sections in a ``<div>`` block and then `includes`_ a template for that section. These included templates are found in the ``sections`` directory in the root ``cv`` template directory. If you would like to customize the look of an individual section, you should write your own templates for the section you want to modify. The name of the section template is the plural of the model name; for example, the template for the :class:`~cv.models.base.Degree` model is ``cv/sections/degrees.html`` (the one exception is the template for :class:`~cv.models.works.OtherWriting`, which is simply ``cv/sections/otherwriting.html``).
40+
.. _CDNs: https://en.wikipedia.org/wiki/Content_delivery_network/
41+
42+
At the next layer, the ``cv/base.html`` template inherits from
43+
``cv/skeleton.html`` and **defines the order of sections** as a
44+
series of Django template blocks. This is done by using `blocks`_
45+
from Django templates. The name of each block corresponds to the
46+
the plural of the model name, except the blocks for
47+
:class:`~cv.models.works.OtherWriting` and
48+
:class:`~cv.models.base.Service` are named ``otherwriting`` and
49+
``service``.
50+
51+
.. _blocks: https://docs.djangoproject.com/en/2.1/ref/templates/builtins/#block
52+
53+
The template ``cv/cv.html`` inherits from the ``cv/base.html``
54+
template and **defines the style for each section**. In the default
55+
template, each block consists of a ``<div>`` block and then
56+
`includes`_ the section template in the ``templates/cv/sections``
57+
directory. The section template is an html file named for the
58+
plural form of the section name (except for :class:`OtherWriting`
59+
and :class:`Service`, as above); for example, the section template
60+
for articles would be the file
61+
``templates/cv/sections/articles.html``. If you would like to
62+
customize the look of an individual section, you should save a
63+
file with that name in the ``cv/sections/`` subdirectory of the
64+
template directory of your own project.
3965

4066
.. _includes: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#include
4167

4268
.. _views-pdf:
4369

4470
PDF
45-
^^^
71+
^^^
72+
73+
Django Vitae will also create a PDF of your CV "on-the-fly".
74+
75+
The PDF version of your CV can be found at the ``/pdf/`` URL. The
76+
URL retrives the view :class:`cv.views.pdf.cv_pdf`. The view
77+
gathers data from different sections of the CV and then creates a
78+
PDF using the `Report Lab`_ library.
79+
80+
.. _Report Lab: https://www.reportlab.com/
81+
82+
**Template Structure**::
83+
84+
cv/
85+
pdf/
86+
pdf_list.json
87+
<model name>.html
88+
89+
Creating PDFs requires that much of the style be controlled
90+
internally in the code. The internal coding makes it difficult to
91+
customize the *style* of the PDF version of the CV. The *content*
92+
can be customized, however, by using templates.
93+
94+
The content of the PDF, including the order, is controlled by the
95+
template ``pdf_list.json`` `JSON`_ file. The JSON file is
96+
structured as a list of dictionaries. Each dictionary **must** have
97+
a ``model_name`` key that is the model name in lowercase. In
98+
addtion, the dictionary **may** have the following keys:
99+
100+
``display_name``
101+
A string of the section heading (including any capitalization
102+
that you desire)
103+
104+
``date_field``
105+
May either be a string representing the name of the field
106+
that you would like to use to display as the date in each
107+
entry for that section **or** a list of two strings, the
108+
field names to be used to render the start and end dates.
109+
110+
``subsections``
111+
A list of lists; each of the sub-lists should include two
112+
string values: the first contains the heading for the
113+
subsection and the second is a string representing the method
114+
of the :attr:`displayable` manager to use to get the queryset
115+
for that subsection.
116+
117+
The ``templates/cv/pdf/`` also contains an XML file for each
118+
section of the PDF. The XML files use the intra-paragraph markup
119+
described in the ReportLab `User Guide`_ (subsection 6.3) that
120+
include the ``<i>`` tag for italics, ``<b>`` for boldface, and
121+
``<a>`` for links (among others).
122+
123+
.. _JSON: https://en.wikipedia.org/wiki/JSON
124+
.. _User Guide: https://www.reportlab.com/docs/reportlab-userguide.pdf
125+
126+
127+

0 commit comments

Comments
 (0)