Différences entre les versions de « GWiki:Archivage automatique »

4 612 octets ajoutés ,  5 février 2008 à 16:12
m
m (Nouvelle page: <includeonly></includeonly><noinclude>__NOEDITSECTION____NOTOC__{{en construction}} == Description == Ce modèle sert à déclarer une page à archiver auprès du robot qui maintient ...)
 
 
(2 versions intermédiaires par le même utilisateur non affichées)
Ligne 2 : Ligne 2 :
== Description ==
== Description ==
Ce modèle sert à déclarer une page à archiver auprès du robot qui maintient les archives.
Ce modèle sert à déclarer une page à archiver auprès du robot qui maintient les archives.
== Utilisation ==
Insérez ce modèle dans la page à archiver (en haut de page pour facilité la lecture) :
<pre><nowiki>
{{Archivage automatique
|algo = old(...)
|archive = Nom de la page d'archives
[autres paramètres - voir ci-dessous]
}}
</nowiki></pre>
Ceci est un exemple, vous devez mettre des paramètres valables pour que le robot les comprenne.
=== Exemples ===
: <span style="color: red;">'''Changez "''Discussion Utilisateur:Exemple''" par le nom de votre page !'''</span>
==== Exemple 1 - Archivage statique ====
<pre><nowiki>
{{Archivage automatique
|algo = old(7d)
|archive = Discussion Utilisateur:Exemple/Archives
}}
</nowiki></pre>
This setup archives threads from [[User talk:Example]] to [[User talk:Example/Archive]] after they are 7 days old (counting from newest timestamp). The archive '''will grow indefinitely'''. Probably not a very useful config (unless for sending threads to a periodically cleaned trash bin), but it's easiest, so I'm mentioning it first.
==== Exemple 2 - Archivage pondéré ====
<pre><nowiki>
{{Archivage automatique
|algo = old(48h)
|archive = Discussion Utilisateur:Exemple/Archive %(counter)d
|counter = 3
|maxarchivesize = 250K
}}
</nowiki></pre>
This tells the bot to archive threads from [[User talk:Example]] to [[User talk:Example/Archive 3]] (more about variables [[#Variables|below]]) until it fills up to 250 kilobytes, whereupon the bot will move to 4 (updating the counter when saving page). Remember to '''specify the maximum size''' of an archive, or it will behave pretty much like in the first example.
==== Exemple 3 - Archivage périodique ====
<pre><nowiki>
{{Archivage automatique
|algo = old(5d)
|archive = Discussion Utilisateur:Exemple/Archives/%(year)d/%(monthname)s
}}
</nowiki></pre>
In this configuration, threads older than 5 days will land in archives depending on their date (that is newest timestamp). You can read about other variables [[#Variables|below]].
=== Paramètres ===
{| class = "prettytable"
! parameter || meaning
|-
| <tt>archive</tt> || Name of the page to which archived threads will be put. Supports [[#Variables|variables]].
|-
| <tt>algo</tt> || Algorithm that instructs the bot how to decide whether to archive a thread or not. Complex formulas (including regex matching) will be available in the future, but so far it '''must''' be of the form '''<tt>old(...)</tt>''' where '''...''' specifies the maximum age of a thread (in hours or days: ''24h'', ''72h'', ''5d'', ''21d'' etc.)
|-
| <tt>counter</tt> || The current value of the counter. If the <tt>%(counter)d</tt> variable is not used, it is ignored. Bot will update this parameter as necessary.
|-
| <tt>maxarchivesize</tt> || The maximum archive size before incrementing the counter. Ignored if counter is not used.
|-
| <tt>minthreadsleft</tt> || The minimum number of threads that should be left on a page (to prevent pages from getting completely harvested). Default value: 5
|-
| <tt>minthreadstoarchive</tt> || The minimum number of threads to archive at one time (lowers edit frequency by refusing to act when only few threads would be archived). Default value: 2
|-
| <tt>archiveheader</tt> || Content that will be put on new archive pages as the header. Supports [[#Variables|variables]]. '''Cannot''' be multiline (use a template like {{tl|archive-nav}}). Defaults to {{tl|talkarchive}}.
|-
| <tt>key</tt> || Secret key that (if valid) allows archives to '''not''' be subpages of the page being archived. To obtain such a key, [[User talk:Misza13|ask me]] and have a good reason for that. :-)
|}
=== Variables ===
{| class = "prettytable"
! variable... || ...expands to...
|-
| <tt>%(counter)d</tt> || the current value of the <tt>counter</tt>
|-
| <tt>%(year)d</tt> || year of the thread being archived
|-
| <tt>%(month)d</tt> || month (as a number 1-12) of the thread being archived
|-
| <tt>%(monthname)s</tt> || English name of the month above
|-
| <tt>%(monthnameshort)s</tt> || first three letters of the name above
|}
Those [[python (programming language)|python]]-savvy people will immediately recognize these variables are filled at runtime with the <tt>%</tt> operator and should know how to adjust the format. A few points of interest to others:
*make sure you don't mess up the last letter after the brackets (it's "d" for [[integer]]s and "s" for [[string (computer science)|strings]])
*integer variables may be left-padded with zeros:
*:<tt>%(counter)03d</tt> evaluates to <tt>013</tt> if the <tt>counter</tt>'s value equals 13,
*:<tt>%(month)02d</tt> becomes <tt>05</tt> for May etc.


[[Catégorie:Archivage]]</noinclude>
[[Catégorie:Archivage]]</noinclude>