-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nettoyage #1505
Merged
Merged
Nettoyage #1505
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
f205584
Use wraps decorator and remove manually wrapping properties
1ee9fab
Rename parameter hiding build in type
f6ef86b
Avoid crash if dictionary is not correctly formatted
d9c5e13
Simplify argument list rendering
713dff2
Adding doc string
85e6c58
Add double underscore to private member.
e4cf402
Rewrite argument list parsing handling bad formatted argument list
181a83e
Change formatting from old style to new one
087f439
Improve error message
5d5526d
not used parameter
4361f20
Small correction
31b5b26
Typo
4683144
Use Djando/Tag template function.
c0eb22b
Rename variable and members
e80bfe3
Remove useless args
658cbb5
Add doc string
ee6a8d7
Rename unused variable.
37275f1
Factorize error catch
4e8fc91
Set all base string formatting on the module beginning
9d32c3d
Use named argument for boolean parameters
1d69098
factorize standard output call.
19d434e
Fix encoding
5029bbd
Doc string
26e918a
remove useless filter argument.
26c120d
Move humane_time filter to date module (not related to markdown)
da0a2f4
Factorise markdown header shift "decale_header"
86588e7
Factorize markdown render + docstring
4c55549
Docstring + comments
2bbb142
Docstring + comments
43c66c5
Add test directory
f2e45ef
Fix: Django do not like partial :(
11a47d9
Fix: allowing empty list in AppendGetNode
14d72ef
Fix: Check value not empty in AppendGetNode
584a6dd
Add Test for "append_to_get" module
7e0eaf4
Add Test for "captureas" module
dc731cf
move const string on top of the module
481b314
Better timedelta argument passing
528c3d2
Add tests to "date" templatetags module
f267126
Fix: Markdown inline not propagated
e96b3b6
Fix: Only add complete match from all
f41ef8e
Fix: shift header
32a677d
Add test to "emarkdown" template tags
13230e7
Fix doc string comment
613f557
Complete doc
b214115
Remove redundant module loading
a9837de
pep-8 correction
e661525
Merge branch 'clean_templatetags' of github.com:cgabard/zds-site into…
da96e7a
Merge with dev
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
|
||
Elements de templates personnalisés | ||
=================================== | ||
|
||
Le package ``zds/utils/templatetags`` contient un ensemble de tags et filtres personnalisés pouvant être utilisés | ||
dans les templates rendues par Django. | ||
|
||
La majorité de ces modules proposent aussi des fonctions proposant les même fonctionnalités depuis le reste du code | ||
Python. | ||
|
||
append_to_get | ||
------------- | ||
|
||
L'élément ``append_to_get`` permet de rajouter des paramètres à la requête ``GET`` courante. Par exemple, sur une page | ||
``module/toto``, le code de template suivant :: | ||
|
||
{% load append_to_get %} | ||
<a href="{% append_to_get page=key1=var1,key2=var2 %}">Mon lien</a> | ||
|
||
produira le code suivant :: | ||
|
||
<a href="module/toto?key1=1&key2=2">Mon lien</a> | ||
|
||
si le contenu de ``var1`` est ``1`` et le contenu de ``var2`` est ``2`` | ||
|
||
captureas | ||
--------- | ||
|
||
L'élément ``captureas`` permet de demander d'effectuer le rendu d'un bloc de template et de stocker son contenu dans | ||
une variable. Ainsi le code suivant :: | ||
|
||
{% load captureas %} | ||
{% captureas var2 %} | ||
{% for i in 'xxxxxxxxxx' %} | ||
{{forloop.counter0}} | ||
{% endfor %} | ||
{% endcaptureas %} | ||
|
||
ne produit rien en sortie mais affecte le résultat du bloc entre les éléments ``{% captureas var2 %}`` et | ||
``{% endcaptureas %}``, soit ``0123456789``, dans la variable de template ``var2`` | ||
|
||
date | ||
---- | ||
|
||
Plusieurs filtres sont disponible dans ce module. | ||
|
||
format_date | ||
+++++++++++ | ||
|
||
Ce filtre formate une date au format ``DateTime`` destiné à être affiché sur le site:: | ||
|
||
{% load date %} | ||
{{ date | format_date}} | ||
|
||
tooltip_date | ||
++++++++++++ | ||
|
||
Ce filtre effectue la même chose que ``format_date`` mais à destination des ``tooltip``. | ||
|
||
humane_time | ||
+++++++++++ | ||
|
||
Formate une date au format *Nombre de seconde depuis Epoch* en un élément lisible. Ainsi :: | ||
|
||
{% load date %} | ||
{{ date_epoch | humane_time}} | ||
|
||
sera rendu :: | ||
|
||
01 Jan 1970, 01:00:42 | ||
|
||
Si le contenu de ``date_epoch`` etait de ``42``. | ||
|
||
emarkdown | ||
--------- | ||
|
||
Markdown vers HTML | ||
++++++++++++++++++ | ||
|
||
Permet de rendre un texte markdown en HTML : | ||
|
||
- ``emarkdown`` : Transforamtion classique | ||
- ``emarkdown_inline`` : Transforamtion uniquement des éléments *inline* et donc pas de blocs. Utilisés pour les | ||
signatures des membres. | ||
|
||
|
||
Markdown vers Markdown | ||
++++++++++++++++++++++ | ||
|
||
Ces élements sont utilisés dans le cadre de la transformation du markdown avant d'être traité par ``Pandoc`` lors de la | ||
génération des fichiers PDF et EPUB des tutos : | ||
|
||
- ``decale_header_1`` : Décale les titres de 1 niveau (un titre de niveau 1 devient un titre de niveau 2, etc.) | ||
- ``decale_header_2`` : Décale les titres de 2 niveaux (un titre de niveau 1 devient un titre de niveau 3, etc.) | ||
- ``decale_header_3`` : Décale les titres de 3 niveaux (un titre de niveau 1 devient un titre de niveau 4, etc.) | ||
|
||
|
||
|
||
autres | ||
------ | ||
|
||
**TODO** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
============= | ||
Autres outils | ||
============= | ||
|
||
Le package ``zds/utils`` contient un certains nombres d'outils transverses. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
templatetags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tu charges 2 fois date ici.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
en effet j'ai pas fait gaffe qu'il était déjà chargé,