diff --git a/README.md b/README.md
index 0dda040..b6f7459 100644
--- a/README.md
+++ b/README.md
@@ -1,78 +1,79 @@
# Italian Wikipedia Deletion Bot
This project aims to handle the public deletion log of Italian Wikipedia pages.
## History of the project
The script was originally developed by Mauro762 (aka MauroBot) in 2013 using JavaScript and previously developed in Python {{Citation needed}}.
## TODO
* [X] Yearly category creation
* [X] Monthy category creation
* [X] Daily category creation
* [X] Daily log page update
-* [ ] Daily counting page update
-* [ ] Most of the work :)
+* [X] Daily counting page update
+* [X] Most of the work :)
+* [ ] Be sure that It doesn't destroy anything
## Installation
apt-get install php-cli
git clone --recursive https://github.com/valerio-bozzolan/ItalianWikipediaDeletionBot
## Basic configuration
Fill `config-example.php` and save-as `config.php`.
## Basic usage
./bot.php
## Hacking
Most of the behaviours — as the content of the categories, the pages, their edit summaries, etc. — can be changed simply hacking the content of the files from the [/templates](/templates) directory. Trust me, you are able to do it.
Start becoming familiar with their structure:
This is the place for some documentation, expecially about "placeholders".
This is the place for a specific example
This is the place for the most important part of this file.
This part is what this template will generates.
It uses stuff like "$1" or "%1%02d" as generic placeholders.
To be honest: everything above the `` line it's pure documentation sugar. It's written to help you. I've spent some minutes on them. Please RTFM. asd
A non-traumatic template example can be found [here](templates/CATEGORY_YEAR.content.tpl). It describes the generation of the yearly category.
## Credits
You may not want to know this: HTTP connections, MediaWiki APIs (including login and tokens etc.), and other stuff, are handled by the [boz-mw](https://github.com/valerio-bozzolan/boz-mw) framework.
## License
Original files released under [Creative Commons BY-SA 3.0 International](https://creativecommons.org/licenses/by-sa/3.0/) and [WMF terms](https://wikimediafoundation.org/wiki/Special:MyLanguage/Terms_of_Use/it) by [Mauro742](https://it.wikipedia.org/wiki/Utente:Mauro742)/[MauroBot](https://it.wikipedia.org/wiki/Utente:MauroBot):
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/main.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/bot.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/category.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/dateFunctions.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/core.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/globals.js
* https://it.wikipedia.org/wiki/Utente:MauroBot/BotCancellazioni/gui.js
Copyright (C) 2018 [Valerio Bozzolan](https://it.wikipedia.org/wiki/Utente:Valerio_Bozzolan)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
diff --git a/bot.php b/bot.php
index c6632b9..1fac5f2 100755
--- a/bot.php
+++ b/bot.php
@@ -1,39 +1,39 @@
#!/usr/bin/php
.
namespace itwikidelbot;
// autoload classes
require __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'autoload.php';
// load credentials
require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
// create the yearly category
$year = date( 'Y' );
( new CategoryYear( $year ) )
->saveIfNotExists();
// create the monthly category
$month = date( 'n' ); // 1-12
( new CategoryYearMonth( $year, $month ) )
->saveIfNotExists();
// create the daily category
$day = date( 'j' );
-( new CategoryYearMonthDay( $year, $month, $day ) )
+( new CategoryYearMonthDayTypes( $year, $month, $day ) )
->saveIfNotExists()
- ->operateEveryChildrenPage();
+ ->run();
diff --git a/config-example.php b/config-example.php
index 270bc21..843a9bc 100644
--- a/config-example.php
+++ b/config-example.php
@@ -1,10 +1,12 @@
.
namespace itwikidelbot;
+use \cli\Log;
+
/**
* Abstraction of a daily category with a specified PDC type
*/
abstract class CategoryYearMonthDayType extends CategoryYearMonthDay {
/**
* Template name of this category
*
* @override CategoryTemplated::TEMPLATE_NAME
*/
const TEMPLATE_NAME = 'CATEGORY_DAY_PDCTYPE';
/**
* PDC type e.g. 'consensuale'
*
* To be overrided
*/
const PDC_TYPE = 'EXAMPLE';
/**
* Get the PDC type
*
* @return string e.g. 'consensuale'
*/
public function getPDCType() {
return static::PDC_TYPE;
}
/**
* Get template arguments
*
* @override CategoryTemplated::getTemplateArguments()
*/
public function getTemplateArguments() {
$parent_arguments = parent::getTemplateArguments();
$parent_arguments[] = $this->getPDCType();
return $parent_arguments;
}
/**
* Create a PDF of this type (from raw)
*
* @param $pdc_raw mixed Raw PDC data
* @see PDC::createFromRaw()
*/
public function createPDCFromRaw( $pdc_raw ) {
- return PDC::createFromRaw( static::getPDCType(), $this->getDateTime(), $pdc_raw );
+ return PDC::createFromRaw( $this, $pdc_raw );
}
/**
* Fetch PDCs of this type
*
* @return array
*/
public function fetchPDCs() {
- $api = self::api()->setApiData( [
+ $api = self::api()->createQuery( [
'action' => 'query',
// generator=categorymembers: get pages in category
// gmtitle=: specify the category title
// gmtype=page: get sub-pages
- // gmsort=timestamp: order by insertion date in that category (completly unuseful)
+ // gmsort=timestamp: order by insertion date in that category
// gmdir=asc: ascending order
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategorymembers
// Note: Generator parameter names must be prefixed with a 'g'
'generator' => 'categorymembers',
'gcmtitle' => $this->getTitle(),
'gcmtype' => 'page', // Note: Ignored when cmsort=timestamp is set.
'gcmlimit' => 100,
-// 'gcmsort' => 'timestamp',
-// 'gcmdir' => 'asc',
-
+ 'gcmsort' => 'timestamp',
+ 'gcmdir' => 'asc',
+//
// for each page load infos, categories and latest revision
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions
// Note: probably the revisions parameter is unuseful for last update date (already provided by "touched").
// Note: revisions can be still useful to know the creation date
- 'prop' => [ 'info' , 'categories', /*'revisions'*/ ],
+ 'prop' => [ 'info' , 'categories'/*, 'revisions'*/ ],
// inprop=protecion: list of the protection level of each page
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Bcategories
'inprop' => 'protection',
// clprop=sortkey: adds the sortkey and sortkey prefix for the category
+ // clprop=timestamp: adds the timestamp of when the page was included
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Binfo
- 'clprop' => 'sortkey',
+ 'clprop' => [ 'sortkey', 'timestamp' ],
// rvprop=timestamp: timestamp of the revision
// rvlimit=1: only 1 revision
// rvdir=older: order by oldest
// https://it.wikipedia.org/w/api.php?action=help&modules=query%2Brevisions
// 'rvprop' => 'timestamp',
// 'rvdir' => 'older',
// 'rvlimit' => 1,
] );
$all = [];
while( $api->hasNext() ) {
$next = $api->fetchNext();
if( isset( $next->query->pages ) ) {
foreach( $next->query->pages as $page ) {
// multiple call will add more infos on the same page
// https://www.mediawiki.org/wiki/API:Query#Generators_and_continuation
// TODO: use batchcomplete for better memory usage
// Note: pages are not directly saved with their pageid to preserve their order
$pageid = $page->pageid;
if( isset( $all[ $pageid ] ) ) {
foreach( $page as $property => $value ) {
$all[ $pageid ]->{$property} = $value;
}
} else {
$all[ $pageid ] = $page;
}
}
}
}
$pdcs = [];
foreach( $all as $page ) {
- $pdc = $this->createPDCFromRaw( $page );
- if( $pdc ) {
- $pdcs[] = $pdc;
+ try {
+ $pdcs[] = $this->createPDCFromRaw( $page );
+ } catch( PDCExpiredException $e ) {
+ Log::info( sprintf(
+ "%s: %s",
+ $page->title,
+ $e->getMessage()
+ ) );
+ } catch( PDCException $e ) {
+ Log::warn( sprintf(
+ "exception in PDC '%s': %s",
+ $page->title,
+ $e->getMessage()
+ ) );
}
}
+
return $pdcs;
}
}
diff --git a/includes/class-CategoryYearMonthDayTypes.php b/includes/class-CategoryYearMonthDayTypes.php
index 9c888d1..8762fa5 100644
--- a/includes/class-CategoryYearMonthDayTypes.php
+++ b/includes/class-CategoryYearMonthDayTypes.php
@@ -1,82 +1,112 @@
.
namespace itwikidelbot;
/**
* Handler of all the PDCs in this day of the year
*/
class CategoryYearMonthDayTypes extends CategoryYearMonthDay {
+ /**
+ * PDC types
+ *
+ * Categories in order of importance (I think)
+ *
+ * @var array
+ */
+ public static $TYPES = [
+ CategoryYearMonthDayTypeVoting ::class,
+ CategoryYearMonthDayTypeProlonged ::class,
+ CategoryYearMonthDayTypeConsensual::class,
+ CategoryYearMonthDayTypeOrdinary ::class,
+ CategoryYearMonthDayTypeSimple ::class,
+ ];
+
+ /**
+ * Return the more precise PDC type between two
+ *
+ * @param $type1 Class name
+ * @param $type2 Class name
+ * @return Class name
+ */
+ public static function bestType( $type1, $type2 ) {
+ $i1 = array_search( self::$TYPES, $type1 );
+ $i2 = array_search( self::$TYPES, $type2 );
+ if( $i1 === false || $i2 === false ) {
+ throw new \InvalidArgumentException( 'cannot compare unknown types' );
+ }
+ return $i1 < $i2 ? $type1 : $type2;
+ }
+
/**
* Operate on every PDC type
*/
public function run() {
- // Categories for PDCs in order of importance (I think)
- $Categories = [
- CategoryYearMonthDayTypeVoting ::class,
- CategoryYearMonthDayTypeProlonged ::class,
- CategoryYearMonthDayTypeConsensual::class,
- CategoryYearMonthDayTypeOrdinary ::class,
- CategoryYearMonthDayTypeSimple ::class,
- ];
-
- $pdcs_by_type = [];
- foreach( $Categories as $Category ) {
+ $pdcs_by_id = [];
+ foreach( self::$TYPES as $Category ) {
$category = new $Category( $this->getYear(), $this->getMonth(), $this->getDay() );
$pdcs = $category->fetchPDCs();
if( count( $pdcs ) ) {
$category->saveIfNotExists();
}
- // sort PDCs by last update
- usort( $pdcs, function ( $a, $b ) {
- return $a->getLasteditDate() > $b->getLasteditDate();
- } );
-
- $pdcs_by_type[ $Category::getPDCType() ] = $pdcs;
+ // merge the same PDCs
+ foreach( $pdcs as $pdc ) {
+ $id = $pdc->getId();
+ if( isset( $pdcs_by_id[ $id ] ) ) {
+ $pdcs_by_id[ $id ]->setType( self::bestType(
+ $pdcs_by_id[ $id ]->getTypeClass(),
+ $pdc ->getTypeClass()
+ ) );
+ } else {
+ $pdcs_by_id[ $id ] = $pdc;
+ }
+ }
}
- $pdcs_by_type = self::filterPDCs( $pdcs_by_type );
+ // sort PDCs by start date
+ usort( $pdcs_by_id, function ( $a, $b ) {
+ return $a->getStartDate() < $b->getStartDate();
+ } );
- PageYearMonthDayPDCsCount::createFromPagePDCs( $this->getDateTime(), $pages_by_type )
- ->save();
+ // index PDcs by their type
+ $pdcs_by_type = [];
+ foreach( $pdcs_by_id as $pdc ) {
+ $type = $pdc->getType();
+ if( ! isset( $pdcs_by_type[ $type ] ) ) {
+ $pdcs_by_type[ $type ] = [];
+ }
+ $pdcs_by_type[ $type ][] = $pdc;
+ }
- PageYearMonthDayPDCsLog::createFromPagePDCs( $this->getDateTime(), $pages_by_type )
+ PageYearMonthDayPDCsCount::createFromDateTimePDCs( $this->getDateTime(), $pdcs_by_type )
->save();
- }
- /**
- * Make a bit of consistence in the specified PDCs
- *
- * @param $pdcs_by_type array
- * @return array
- * @TODO
- */
- private static function filterPDCs( $pdcs_by_type ) {
- return $pdcs_by_type;
+ PageYearMonthDayPDCsLog::createFromDateTimePDCs( $this->getDateTime(), $pdcs_by_type )
+ ->save();
}
}
diff --git a/includes/class-Date.php b/includes/class-Date.php
deleted file mode 100644
index b3008b4..0000000
--- a/includes/class-Date.php
+++ /dev/null
@@ -1,66 +0,0 @@
-.
-
-namespace itwikidelbot;
-
-use DateTime;
-
-/**
- * Handle a human date
- */
-class Date {
-
- /**
- * Get a DateTime object from a human date
- *
- * @param $category_name Category name e.g. '4 aprile 2013'
- * @return DateTime
- */
- public static function human2object( $human_date ) {
- $parts = explode( ' ', $human_date );
- if( 3 === count( $parts ) ) {
- list( $d, $human_m, $y ) = $parts;
- $m = Months::name2number( $human_m ) + 1;
- return new DateTime( sprintf(
- // yyyy-mm-dd
- '%s-%02d-%02s',
- $y,
- $m,
- $d
- ) );
- }
- throw new \InvalidArgumentException( 'wrong human date' );
- }
-
- /**
- * Get a human date from a DateTime object
- *
- * @param $datetime DateTime
- * @return string e.g. '4 aprile 2013'
- */
- public static function object2human( DateTime $datetime ) {
- list( $y, $m, $d ) = explode( ' ', $datetime->format('Y m d') );
- $human_month = Months::number2name( $m - 1 );
- return "$d $human_month $y";
- }
-}
diff --git a/includes/class-PDC.php b/includes/class-PDC.php
index 5447c90..7318613 100644
--- a/includes/class-PDC.php
+++ b/includes/class-PDC.php
@@ -1,353 +1,440 @@
.
namespace itwikidelbot;
use DateTime;
/**
* Handle a "Procedura di cancellazione"
*
* It is a page like "Wikipedia:Pagine da cancellare/ASD"
*/
class PDC extends Page {
/**
* Prefix of every PDC
*/
const PREFIX = 'Wikipedia:Pagine da cancellare/';
/**
* Prefix of every multiple PDC
*/
const PREFIX_MULTIPLE = self::PREFIX . 'multiple/';
/**
- * PDC type
+ * PDC category type
*
- * @var string
+ * @var CategoryYearMonthDayType
*/
- private $type;
+ private $categoryType;
/**
* Page id
*
* @var int
*/
private $id;
/**
* Title of the PDC subject page (the Wikipedia article title)
*
* Obtained from {{DEFAULTSORT}} category sortkey
*
* @var string
*/
private $titleSubject;
/**
* Page length in bytes
*
* @var int
*/
private $length;
/**
- * Date of the PDC
+ * When the PDC was added to the PDC type category
*
* @var date
*/
- private $creationDate;
+ private $startDate;
/**
* Last update
*
* @var date
*/
private $lasteditDate;
/**
* Is Protected?
*
* @var bool
*/
private $isProtected;
+ /**
+ * Properties that the raw object must have
+ *
+ * @var array
+ */
+ private static $RAW_PROPERTIES = [
+ 'pageid',
+ 'title',
+ 'length',
+ 'touched',
+ 'protection',
+ 'categories'
+ ];
+
/**
* Constructor
*
- * @param $type string PDC type
+ * @param $category_type CategoryYearMonthDayType PDC category type
* @param $id int PDC page id
* @param $title string PDC title prefixed
* @param $title_subject string Title of the subject page (the Wikipedia article title)
* @param $length int PDC length
- * @param $creation DateTime PDC creation date
+ * @param $start DateTime When the PDC was added to the PDC type category
* @param $lastedit DateTime PDC lastedit date
* @param $is_protected bool Is the PDC protected?
* @see Page::__construct()
* @throws PDCException
*/
- public function __construct( $type, $id, $title, $title_subject, $length, DateTime $creation, DateTime $lastedit, $is_protected ) {
- $this->type = $type;
+ public function __construct( $category_type, $id, $title, $title_subject, $length, DateTime $start, DateTime $lastedit, $is_protected ) {
+ $this->categoryType = $category_type;
$this->id = $id;
$this->titleSubject = $title_subject;
$this->length = $length;
- $this->creationDate = $creation;
+ $this->startDate = $start;
$this->lasteditDate = $lastedit;
$this->isProtected = $is_protected;
parent::__construct( $title );
+ // consistence checks
if( ! $this->isTitlePrefixValid() ) {
throw new PDCException( 'not a PDC' );
-
}
-
- if( ! $this->isTitleSubjectConsistent() ) {
- throw new PDCException( 'inconsistent title subject' );
+ if( $this->getDurationDays() > 7 ) {
+ throw new PDCExceptionExpired( 'not anymore a PDC of type ' . $this->getType() );
}
+
+ $this->checkTitleSubjectConsistence();
+ }
+
+ /**
+ * Get the page id
+ *
+ * @return int
+ */
+ public function getId() {
+ return $this->id;
}
/**
* Get the title of the subject page (the Wikipedia article title)
*
* Obtained from {{DEFAULTSORT}} category sortkey
*
* @return string
*/
public function getTitleSubject() {
return $this->titleSubject;
}
/**
* Get the page length
*
* @return int
*/
public function getLength() {
return $this->length;
}
/**
- * Get the creation date
+ * Get the start date of this PDC (of this type)
*
* @return DateTime
*/
- public function getCreationDate() {
- return $this->creationDate;
+ public function getStartDate() {
+ return $this->startDate;
}
/**
* Get the latest update date
*
* @return DateTime
*/
public function getLasteditDate() {
return $this->lasteditDate;
}
/**
- * Get the PDC type
+ * Get the PDC type class
+ *
+ * @return class
+ */
+ public function getTypeClass() {
+ return $this->categoryType;
+ }
+
+ /**
+ * Get the PDC type name
*
* @return string e.g. 'consensuale'
*/
public function getType() {
- return $this->type::getPDCType();
+ return $this->getTypeClass()::getPDCType();
+ }
+
+ /**
+ * Get the PDC color
+ *
+ * @return string
+ */
+ public function getColor() {
+ return Template::get( 'PDC.' . $this->getType() . '.color' );
+ }
+
+ /**
+ * Get the PDC go to action label
+ *
+ * @return string
+ */
+ public function getGotoActionLabel() {
+ return Template::get( 'PDC.' . $this->getType() . '.goto' );
}
/**
* Check if this page is protected
*
* @return bool
*/
public function isProtected() {
return $this->isProtected;
}
/**
* Check if this PDC has a known prefix
*
* @return bool
*/
private function isTitlePrefixValid() {
return $this->titlehasPrefix( self::PREFIX );
}
/**
* Check if this PDC involves multiple PDCs
*
* @return bool
*/
public function isMultiple() {
return $this->titleHasPrefix( self::PREFIX_MULTIPLE );
}
/**
* Get the title prefix
*
* @return string
*/
private function getTitlePrefix() {
return $this->isMultiple()
? self::PREFIX_MULTIPLE
: self::PREFIX;
}
/**
* Get the title unprefixed
*
* @return string
*/
private function getTitleUnprefixed() {
return substr( $this->getTitle(), strlen( $this->getTitlePrefix() ) );
}
/**
* Check if the title has a certain prefix
*
* @param $prefix string
* @return bool
*/
private function titleHasPrefix( $prefix ) {
return 0 === strpos( $this->getTitle(), $prefix );
}
/**
* Verify if the title of the subject is consistent with the PDC title
*
* @return bool
*/
- private function isTitleSubjectConsistent() {
+ private function checkTitleSubjectConsistence() {
// subject from {{DEFAULTSORT}} category prefix
$subject = $this->getTitleSubject();
// subject generated unprefixing page title
$subject_gen = $this->getTitleUnprefixed();
if( $subject !== $subject_gen ) {
// Check if the PDC title ends with an enumeration e.g. 'asd/14'
$status = preg_match( '@(.*)/[0-9]+$@', $subject_gen, $matches );
if( 1 === $status ) {
// Get the interesting part e.g. 'asd'
$subject_gen = $matches[ 1 ];
}
}
- return $subject === $subject_gen;
+ if( $subject !== $subject_gen ) {
+ throw new PDCException( sprintf(
+ 'the sortkey is "%s" and it is inconsistent with the PDC suffix "%s"',
+ $subject_gen,
+ $subject
+ ) );
+ }
}
/**
- * Statical constructor
+ * Static constructor
*
- * @param $type string Specified PDC class name
- * @param $creation DateTime Creation date (PDC date)
+ * @param $type CategoryYearMonthDayType Specified PDC type
* @param $page mixed
* @return self
* @throws PDCException
*/
- public static function createFromRaw( $type, DateTime $creation, $page ) {
+ public static function createFromRaw( $type, $page ) {
// verify consistence
- if( ! isset(
- $page->pageid,
- $page->title,
- $page->length,
- $page->touched,
- $page->protection,
- $page->categories
- ) ) {
- throw new PDCException( 'invalid PDC' );
+ foreach( self::$RAW_PROPERTIES as $property ) {
+ if( ! isset( $page->$property ) ) {
+ throw new PDCException( "PDC has not property $property" );
+ }
}
// read the title of the subject from the {{DEFAULTSORT}} category sortkey prefix
- $title_subject = '';
+ // get the start date of this PDC from the timestamp
+ $title_subject = null;;
+ $date_added_in_category = null;
foreach( $page->categories as $category ) {
- if( ! isset( $category->sortkeyprefix ) ) {
- throw new PDCException( 'missing category sortkey prefix' );
+ if( ! isset( $category->title ) ) {
+ throw new PDCException( 'missing category title' );
+ }
+ if( $category->title === $type->getTitle() ) {
+ $title_subject = $category->sortkeyprefix;
+ $date_added_in_category = $category->timestamp;
}
- $title_subject = $category->sortkeyprefix;
break;
}
+ if( ! isset( $title_subject ) ) {
+ throw new PDCException( 'missing category sortkey prefix that contains title subject' );
+ }
+ if( ! isset( $date_added_in_category ) ) {
+ throw new PDCException( 'missing timestamp that contains the PDC start date' );
+ }
// read protection status
$is_protected = false;
foreach( $page->protection as $protection ) {
if( 'edit' === $protection->type && 'sysop' === $protection->level ) {
$is_protected = true;
break;
}
}
return new self(
$type,
- $page->pageid,
+ (int) $page->pageid,
$page->title,
$title_subject,
- $page->length,
- $creation,
+ (int) $page->length,
+ DateTime::createFromFormat( DateTime::ISO8601, $date_added_in_category ),
DateTime::createFromFormat( DateTime::ISO8601, $page->touched ),
$is_protected
);
}
/**
* Get the PDC temperature
*
* The temperature is a value betweeen 0-100
*
* @return int
*/
public function getTemperature() {
$slope = null;
$offset = null;
switch( $this->getType() ) {
case CategoryYearMonthDayTypeSimple::getPDCType():
$slope = 0.0365;
$offset = -24.0;
break;
case CategoryYearMonthDayTypeConsensual::getPDCType():
$slope = 0.0075;
$offset = -12.81;
break;
case CategoryYearMonthDayTypeProlonged::getPDCType():
$slope = 0.0035;
$offset = -9.76;
break;
case CategoryYearMonthDayTypeOrdinary::getPDCType():
case CategoryYearMonthDayTypeVoting ::getPDCType():
$slope = 0.0025;
$offset = -16.43;
break;
default:
- throw new \Exception( 'unexpected type' );
+ throw new PDCException( 'unexpected type' );
}
$temp = round( $slope * $this->getLength() + $offset );
if ( $temp > 100 ) {
$temp = 100;
} elseif ( $temp < 0 ) {
$temp = 0;
}
return $temp;
}
+
+ /**
+ * Get the number of days of duration of this PDC
+ *
+ * @return int
+ */
+ public function getDurationDays() {
+ return (int) $this->getStartDate()->diff( $this->getLasteditDate() )->format('%a');
+ }
+
+ /**
+ * Get an human rappresentation of the duration of this PDC
+ *
+ * @return string
+ */
+ public function getHumanDuration() {
+ $days = $this->getDurationDays();
+ if( 0 === $days ) {
+ return Template::get( 'DURATION.hours' );
+ }
+ if( 1 === $days ) {
+ return Template::get( 'DURATION.day' );
+ }
+ return Template::get( 'DURATION.days', [ $days ] );
+ }
}
diff --git a/bot.php b/includes/class-PDCExpiredException.php
old mode 100755
new mode 100644
similarity index 55%
copy from bot.php
copy to includes/class-PDCExpiredException.php
index c6632b9..c85bc5f
--- a/bot.php
+++ b/includes/class-PDCExpiredException.php
@@ -1,39 +1,23 @@
-#!/usr/bin/php
.
namespace itwikidelbot;
-// autoload classes
-require __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'autoload.php';
-
-// load credentials
-require __DIR__ . DIRECTORY_SEPARATOR . 'config.php';
-
-// create the yearly category
-$year = date( 'Y' );
-( new CategoryYear( $year ) )
- ->saveIfNotExists();
-
-// create the monthly category
-$month = date( 'n' ); // 1-12
-( new CategoryYearMonth( $year, $month ) )
- ->saveIfNotExists();
-
-// create the daily category
-$day = date( 'j' );
-( new CategoryYearMonthDay( $year, $month, $day ) )
- ->saveIfNotExists()
- ->operateEveryChildrenPage();
+/**
+ * Exceptions to be thrown when a PDC is not anymore of a certain type
+ * because it expired.
+ */
+class PDCExpiredException extends PDCException {};
diff --git a/includes/class-Page.php b/includes/class-Page.php
index 0d649c4..ad7a9f1 100644
--- a/includes/class-Page.php
+++ b/includes/class-Page.php
@@ -1,165 +1,160 @@
.
namespace itwikidelbot;
+use \cli\Input;
use \wm\WikipediaIt;
use \mw\Tokens;
/**
* Handle a page
*/
class Page {
/**
- * Do nothing
+ * Enable this flag to ask for every changes
*
* @var bool
*/
- public static $PORCELAIN = false;
-
- /**
- * Debug mode
- *
- * @var bool
- */
- public static $INSPECT = false;
+ public static $ASK_BEFORE_SAVING = false;
/**
* @var string Page title with prefix
*/
private $title;
/**
* Construct a Page
*
* @param $title Page title with its prefix
*/
public function __construct( $title ) {
$this->title = $title;
}
/**
* Get the page title with its prefix
*
* @return string
*/
public function getTitle() {
return $this->title;
}
/**
* Save this page
*
* @param $content string Page content
* @param $summary string Edit summary
* @return bool|mixed False if not created
*/
public function saveByContentSummary( $content, $summary ) {
return static::saveByTitleContentSummary( $this->getTitle(), $content, $summary );
}
/**
* Save this page if it does not exist
*
* @param $content string Page content
* @param $summary string Edit summary
* @return bool|mixed False if not created
*/
public function saveByContentSummaryIfNotExists( $content, $summary ) {
return self::saveByTitleContentSummaryIfNotExists( $this->getTitle(), $content, $summary );
}
/**
* Check if this page exists
*
* @return bool
*/
public function exists() {
return static::existsByTitle( $this->getTitle() );
}
/**
* Save a page
*
* @param $title string Page name with prefix
* @param $content string Page content
* @param $summary string Edit summary
* @return mixed Response
*/
public static function saveByTitleContentSummary( $title, $content, $summary ) {
$api = self::api();
$args = [
'action' => 'edit',
'title' => $title,
'text' => $content,
'summary' => $summary,
'token' => $api->login()->getToken( Tokens::CSRF ),
'bot' => 1,
];
- if( self::$INSPECT ) {
+ $save = true;
+ if( self::$ASK_BEFORE_SAVING ) {
print_r( $args );
- $handle = fopen( 'php://stdin', 'r' );
- $line = fgets( $handle );
- fclose( $handle );
+ if( 'y' !== Input::yesNoQuestion( "Save?" ) ) {
+ $save = false;
+ }
}
- if( ! self::$PORCELAIN ) {
+ if( $save ) {
return $api->post( $args );
}
}
/**
* Save a page if it does not exist
*
* @param $title string Page name with prefix
* @param $content string Page content
* @param $summary string Edit summary
* @return bool|mixed False if not created
*/
public static function saveByTitleContentSummaryIfNotExists( $title, $content, $summary ) {
if( ! static::existsByTitle( $title ) ) {
return static::saveByTitleContentSummary( $title, $content, $summary );
}
return false;
}
/**
* Check if a page title exists
*
* @param $title string Page name with prefix
* @return bool
*/
public static function existsByTitle( $title ) {
$result = self::api()->fetch( [
'action' => 'query',
'prop' => 'info',
'titles' => $title,
] );
foreach( $result->query->pages as $pageid => $page ) {
return ! isset( $page->missing );
}
return false;
}
/**
* Get the API related to this page
*
* @return mw\API
*/
protected static function api() {
return WikipediaIt::getInstance();
}
}
diff --git a/includes/class-PageYearMonthDayPDCs.php b/includes/class-PageYearMonthDayPDCs.php
index ab8a43b..f66d11e 100644
--- a/includes/class-PageYearMonthDayPDCs.php
+++ b/includes/class-PageYearMonthDayPDCs.php
@@ -1,65 +1,101 @@
.
namespace itwikidelbot;
/**
* Abstraction of a page containing PDCs of a day
*/
abstract class PageYearMonthDayPDCs extends PageYearMonthDay {
/**
* PDCs indexed by type
*
* @var array
*/
private $pdcsByType;
/**
* Constructor
*
* @param $year int
* @param $month int 1-12
* @param $day int 1-31
* @param $pdcs_by_type array PDCs by type
* @see PageYearMonthDay::__construct()
*/
public function __construct( $year, $month, $day, $pdcs_by_type ) {
$this->pdcsByType = $pdcs_by_type;
parent::__construct( $year, $month, $day );
}
/**
- * Static constructor from a PageYearMonthDay object
+ * Static constructor
*
- * @param $page PageYearMonthDay
- * @param $pdcs PDCs by type
+ * @param $datetime DateTime
+ * @param $pdcs_by_type PDCs by type
* @return self
*/
- public static function createFromPagePDCs( PageYearMonthDay $page, $pdcs_by_type ) {
- return new static( $page->getYear(), $page->getMonth(), $page->getDay(), $pdcs_by_type );
+ public static function createFromDateTimePDCs( $datetime, $pdcs_by_type ) {
+ return new static( $datetime->format('Y'), $datetime->format('m'), $datetime->format('d'), $pdcs_by_type );
}
/**
* Get the PDCs indexed by type
*
* @return array
*/
public function getPDCsByType() {
return $this->pdcsByType;
}
+ /**
+ * Get the running PDCs indexed by type
+ *
+ * @return array
+ */
+ public function getRunningPDCsByType() {
+ return $this->getPDCsByTypeFilteringProtection( false );
+ }
+
+ /**
+ * Get the ended PDCs indexed by type
+ *
+ * @return array
+ */
+ public function getEndedPDCsByType() {
+ return $this->getPDCsByTypeFilteringProtection( true );
+ }
+
+ /**
+ * Get the PDCs indexed by type, but only which of them are protected (or not)
+ *
+ * @param $is_protected bool
+ * @return array
+ */
+ private function getPDCsByTypeFilteringProtection( $is_protected ) {
+ $pdcs_by_type = $this->getPDCsByType();
+ foreach( $pdcs_by_type as $type => $pdcs ) {
+ foreach( $pdcs as $i => $pdc ) {
+ if( $pdc->isProtected() !== $is_protected ) {
+ unset( $pdcs_by_type[ $type ][ $i ] );
+ }
+ }
+ }
+ return $pdcs_by_type;
+ }
+
}
diff --git a/includes/class-PageYearMonthDayPDCsCount.php b/includes/class-PageYearMonthDayPDCsCount.php
index 6fd817d..2b2e5e2 100644
--- a/includes/class-PageYearMonthDayPDCsCount.php
+++ b/includes/class-PageYearMonthDayPDCsCount.php
@@ -1,68 +1,109 @@
.
namespace itwikidelbot;
/**
* Abstraction of a page containing PDCs' log of the day
*/
class PageYearMonthDayPDCsCount extends PageYearMonthDayPDCs {
/**
* Template name of this page
*
* @override CategoryTemplated::TEMPLATE_NAME
*/
const TEMPLATE_NAME = 'PAGE_COUNT';
/**
* Get the template arguments
*
* @override PageTemplated::getTemplateArguments()
* @return array
*/
public function getTemplateArguments() {
- $args = parent::getTemplateArguments();
$sections = [];
- foreach( $this->getPDCsByType() as $pdcs ) {
- if( $pdcs ) {
- $type = $pdcs[ 0 ]->getType();
- // call the entry template for each PDC
- $entries = [];
- foreach( $pdcs as $pdc ) {
- $entries[] = Template::get( self::TEMPLATE_NAME . '.entry', [
- $pdc->getTitle(),
- $pdc->getTemperature(),
- ] );
- }
+ // runnings
+ $i = 0;
+ $entries = [];
+ foreach( $this->getRunningPDCsByType() as $type => $pdcs ) {
+ foreach( $pdcs as $pdc ) {
+ $entries[] = $this->createPDCEntryContent( $i++, $pdc );
+ }
+ }
+ if( $entries ) {
+ $sections[] = Template::get( self::TEMPLATE_NAME . '.RUNNING.section', [
+ implode( "\n", $entries )
+ ] );
+ }
- // call the section template for each PDC type
- $entries_txt = implode( "\n", $entries );
- $sections[] = Template::get( self::TEMPLATE_NAME . '.section', [
- $pdc->getType(),
- $entries_txt
- ] );
+ // endeds
+ $i = 0;
+ $entries = [];
+ foreach( $this->getEndedPDCsByType() as $type => $pdcs ) {
+ foreach( $pdcs as $pdc ) {
+ $entries[] = $this->createPDCEntryContent( $i++, $pdc );
}
}
+ if( $entries ) {
+ $sections[] = Template::get( self::TEMPLATE_NAME . '.ENDED.section', [
+ implode( "\n", $entries )
+ ] );
+ }
+
+ $args = parent::getTemplateArguments();
- $args[] = implode( "\n", $sections );
+ // Does it have content?
+ if( $sections ) {
+ $args[] = implode( "\n", $sections );
+ } else {
+ $args[] = Template::get( self::TEMPLATE_NAME . '.empty' );
+ }
return $args;
}
+ /**
+ * Get the PDC entry content
+ *
+ * @param $pdc PDC
+ * @param $i Ordinal number passed from the count page
+ * @return string
+ */
+ public function createPDCEntryContent( $i, PDC $pdc ) {
+
+ $template_name = self::TEMPLATE_NAME;
+ $template_name .= $pdc->isProtected()
+ ? '.ENDED.entry'
+ : '.RUNNING.entry';
+
+ return Template::get( $template_name, [
+ $pdc->getTitleSubject(),
+ $pdc->getTemperature(),
+ $pdc->isMultiple() ? Template::get( 'PAGE_COUNT.entry.multiple_note' ) : '',
+ $pdc->getColor(),
+ $i,
+ $pdc->getType(),
+ $pdc->getHumanDuration(),
+ $this->getTitle(),
+ $pdc->getGotoActionLabel(),
+ ] );
+
+ }
+
}
diff --git a/includes/class-PageYearMonthDayPDCsLog.php b/includes/class-PageYearMonthDayPDCsLog.php
index 1900b89..179c6af 100644
--- a/includes/class-PageYearMonthDayPDCsLog.php
+++ b/includes/class-PageYearMonthDayPDCsLog.php
@@ -1,69 +1,67 @@
.
namespace itwikidelbot;
/**
* Abstraction of a page containing PDCs daily log
*
* e.g. https://it.wikipedia.org/wiki/Wikipedia:Pagine_da_cancellare/Conta/2017_aprile_20
*/
class PageYearMonthDayPDCsLog extends PageYearMonthDayPDCs {
/**
* Template name of this page
*
* @override CategoryTemplated::TEMPLATE_NAME
*/
const TEMPLATE_NAME = 'PAGE_LOG';
/**
* Get the template arguments
*
* @override PageTemplated::getTemplateArguments()
* @return array
*/
public function getTemplateArguments() {
$args = parent::getTemplateArguments();
$sections = [];
foreach( $this->getPDCsByType() as $pdcs ) {
if( $pdcs ) {
- $type = $pdcs[ 0 ]->getType();
+ $type = reset( $pdcs )->getType();
// call the entry template for each PDC
$entries = [];
foreach( $pdcs as $pdc ) {
- $entries[] = Template::get( self::TEMPLATE_NAME . '.entry', [
- $pdc->getTitle()
- ] );
+ $entries[] = "{{" . $pdc->getTitle() . "}}";
}
// call the section template for each PDC type
$entries_txt = implode( "\n", $entries );
$sections[] = Template::get( self::TEMPLATE_NAME . '.section', [
$pdc->getType(),
$entries_txt
] );
}
}
$args[] = implode( "\n", $sections );
return $args;
}
}
diff --git a/templates/DURATION.day.tpl b/templates/DURATION.day.tpl
new file mode 100644
index 0000000..aa692c1
--- /dev/null
+++ b/templates/DURATION.day.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the human duration of a PDC.
+
+Applied when the PDC is 1 day old.
+
+
+un giorno
diff --git a/templates/DURATION.days.tpl b/templates/DURATION.days.tpl
new file mode 100644
index 0000000..94ba777
--- /dev/null
+++ b/templates/DURATION.days.tpl
@@ -0,0 +1,13 @@
+
+This is the template for the human duration of a PDC.
+
+Applied when the PDC is more than 1 day old.
+
+Placeholder:
+ %1$d: number of days
+
+
+2 giorni
+
+
+%1$d giorni
diff --git a/templates/DURATION.hours.tpl b/templates/DURATION.hours.tpl
new file mode 100644
index 0000000..44452a5
--- /dev/null
+++ b/templates/DURATION.hours.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the human duration of a PDC.
+
+Applied when the PDC is less than 1 day old.
+
+
+meno di un giorno
diff --git a/templates/PAGE_COUNT.ENDED.entry.tpl b/templates/PAGE_COUNT.ENDED.entry.tpl
new file mode 100644
index 0000000..c094641
--- /dev/null
+++ b/templates/PAGE_COUNT.ENDED.entry.tpl
@@ -0,0 +1,30 @@
+
+This is the template for a single ended PDC in the daily counting page.
+
+Placeholders:
+ %1$s: page title
+ %2$d: temperature
+ %3$s: small note shown only if this PDC is multiple (PAGE_COUNT.entry.multiple_note.tpl)
+ %4$s: color associated to the PDC e.g. #fff
+ %5%d: number of the row
+ %6$s: PDC type e.g. 'consensuale'
+ %7%s: duration
+ %8%s: title of the log page
+ %9$s: goto action label e.g. 'pagina di discussione'
+
+
+
+ | 1 |
+ consensuale |
+ 8 giorni |
+ '''[[:ASD]]''' ([[{{#ifeq:{{PAGENAME}}|Pagine da cancellare|Pagine da cancellare|Wikipedia:Pagine da cancellare/ASD|Wikipedia:Pagine da cancellare/Log/2018 aprile 17#ASD}}|vai alla discussione]]) '''Nota:''' [[Wikipedia:Cancellazioni multiple|procedura di cancellazione multipla]] |
+
+
+
+
+ | %5$d |
+ %6$s |
+ %7%s |
+ '''[[:%1$s]]''' ([[:{{#ifeq:{{PAGENAME}}|Pagine da cancellare|%1$s|%8$s#%1$s}}|vai alla %9$s]]) %3$s |
+
+
diff --git a/templates/PAGE_COUNT.ENDED.footer.tpl b/templates/PAGE_COUNT.ENDED.footer.tpl
new file mode 100644
index 0000000..795f19e
--- /dev/null
+++ b/templates/PAGE_COUNT.ENDED.footer.tpl
@@ -0,0 +1,26 @@
+PAGE_COUNT.entry.multiple_note.tpl
+This is the template for the content of a daily counting page.
+
+Placeholders:
+ %1$d: year
+ %2$d: month 1-12
+ %2$02d: month 01-12
+ %3$s: month name
+ %4$d: day 1-31
+ %4$02d: day 01-31
+ %5$s: now (date formatted by the DATETIME.tpl)
+ %6$s: mega table of PDCs
+
+
+Ultimo aggiornamento: 10:12 aprile 2018
+
+
+
+__NOTOC__
+
+
+Ultimo aggiornamento: %5$s
+
+%6$s
+
+__NOTOC__
diff --git a/templates/PAGE_COUNT.ENDED.header.tpl b/templates/PAGE_COUNT.ENDED.header.tpl
new file mode 100644
index 0000000..795f19e
--- /dev/null
+++ b/templates/PAGE_COUNT.ENDED.header.tpl
@@ -0,0 +1,26 @@
+PAGE_COUNT.entry.multiple_note.tpl
+This is the template for the content of a daily counting page.
+
+Placeholders:
+ %1$d: year
+ %2$d: month 1-12
+ %2$02d: month 01-12
+ %3$s: month name
+ %4$d: day 1-31
+ %4$02d: day 01-31
+ %5$s: now (date formatted by the DATETIME.tpl)
+ %6$s: mega table of PDCs
+
+
+Ultimo aggiornamento: 10:12 aprile 2018
+
+
+
+__NOTOC__
+
+
+Ultimo aggiornamento: %5$s
+
+%6$s
+
+__NOTOC__
diff --git a/templates/PAGE_COUNT.ENDED.section.tpl b/templates/PAGE_COUNT.ENDED.section.tpl
new file mode 100644
index 0000000..3ae40ac
--- /dev/null
+++ b/templates/PAGE_COUNT.ENDED.section.tpl
@@ -0,0 +1,24 @@
+
+This is the template for a section of a daily counting page.
+
+This is the section for ended PDCs.
+
+Placeholders:
+ %1$s: PDC rows
+ %%: a literal '%'
+
+
+
+
+ | [[File:Pictogram voting wait blue.svg|20px|link=]] |
+ Cancellazioni in corso |
+ Ultimo aggiornamento: ~~~~~ |
+
+
+ | # |
+ Modalità |
+ |
+ Titolo |
+
+%1$s
+
diff --git a/templates/PAGE_COUNT.RUNNING.entry.tpl b/templates/PAGE_COUNT.RUNNING.entry.tpl
new file mode 100644
index 0000000..a294a27
--- /dev/null
+++ b/templates/PAGE_COUNT.RUNNING.entry.tpl
@@ -0,0 +1,32 @@
+
+This is the template for a single running PDC in the daily counting page.
+
+Placeholders:
+ %1$s: page title
+ %2$d: temperature
+ %3$s: small note shown only if this PDC is multiple
+ see the template PAGE_COUNT.entry.multiple_note.tpl
+ %4$s: color associated to the PDC e.g. '#fff'
+ %5%d: number of the row
+ %6$s: PDC type e.g. 'consensuale'
+ %7%s: duration e.g. 'un giorno'
+ see the template DURATION_*.tpl
+ %8%s: title of the log page
+ %9$s: goto action label e.g. 'pagina di discussione'
+
+
+
+ | 1 |
+ consensuale |
+ {{Termometro|__temperatura__}} |
+ '''[[:ASD]]''' ([[{{#ifeq:{{PAGENAME}}|Pagine da cancellare|Wikipedia:Pagine da cancellare/ASD|Wikipedia:Pagine da cancellare/Log/2018 aprile 17#ASD}}|vai alla discussione]]) '''Nota:''' [[Wikipedia:Cancellazioni multiple|procedura di cancellazione multipla]]
+ |
+
+
+
+
+ | %5$d |
+ %6$s |
+ {{Termometro|%2$d}} |
+ '''[[:%1$s]]''' ([[:{{#ifeq:{{PAGENAME}}|Pagine da cancellare|%1$s|%8$s#%1$s}}|%9$s]]) %3$s |
+
diff --git a/templates/PAGE_COUNT.RUNNING.footer.tpl b/templates/PAGE_COUNT.RUNNING.footer.tpl
new file mode 100644
index 0000000..6bbf6ac
--- /dev/null
+++ b/templates/PAGE_COUNT.RUNNING.footer.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the footer of running PDCs in a daily log page.
+
+
+
diff --git a/templates/PAGE_COUNT.RUNNING.header.tpl b/templates/PAGE_COUNT.RUNNING.header.tpl
new file mode 100644
index 0000000..d5183a2
--- /dev/null
+++ b/templates/PAGE_COUNT.RUNNING.header.tpl
@@ -0,0 +1,15 @@
+
+This is the template for the header of running PDCs in a daily log page.
+
+
+
+
+ | [[File:Ambox padlock red.svg|20px|link=]] |
+ Cancellazioni concluse |
+
+
+ | # |
+ Modalità |
+ Durata |
+ Titolo |
+
diff --git a/templates/PAGE_COUNT.RUNNING.section.tpl b/templates/PAGE_COUNT.RUNNING.section.tpl
new file mode 100644
index 0000000..2bd9a89
--- /dev/null
+++ b/templates/PAGE_COUNT.RUNNING.section.tpl
@@ -0,0 +1,24 @@
+
+This is the template for a section of a daily counting page.
+
+This is the section for running PDCs.
+
+Placeholders:
+ %1$s: PDC rows
+ %%: a literal '%'
+
+
+
+
+ | [[File:Pictogram voting wait blue.svg|20px|link=]] |
+ Cancellazioni in corso |
+ Ultimo aggiornamento: ~~~~~ |
+
+
+ | # |
+ Modalità |
+ |
+ Titolo |
+
+%1$s
+
diff --git a/templates/PAGE_COUNT.content.tpl b/templates/PAGE_COUNT.content.tpl
index e14ddbb..2fb9f38 100644
--- a/templates/PAGE_COUNT.content.tpl
+++ b/templates/PAGE_COUNT.content.tpl
@@ -1,25 +1,16 @@
This is the template for the content of a daily counting page.
Placeholders:
%1$d: year
%2$d: month 1-12
%2$02d: month 01-12
%3$s: month name
%4$d: day 1-31
%4$02d: day 01-31
%5$s: mega table of PDCs
-
-{{#ifexpr:{{#timel:U}}-{{#timel:U|2018-4-20}}<8*24*3600|{{Utente:MauroBot/BotCancellazioni/Avvisi}}}}
-
-
-
-__NOTOC__
-
-{{#ifexpr:{{#timel:U}}-{{#timel:U|2018-4-20}}<8*24*3600|{{Utente:MauroBot/BotCancellazioni/Avvisi}}}}
-
+{{#ifexpr:{{#timel:U}}-{{#timel:U|2018-4-28}}<8*24*3600|{{Utente:MauroBot/BotCancellazioni/Avvisi}}}}
%5$s
-
__NOTOC__
diff --git a/templates/PAGE_COUNT.empty.tpl b/templates/PAGE_COUNT.empty.tpl
index f5ad113..558086c 100644
--- a/templates/PAGE_COUNT.empty.tpl
+++ b/templates/PAGE_COUNT.empty.tpl
@@ -1,21 +1,10 @@
This is the template for an empty daily counting page.
-Placeholders:
- %1$s: now timestamp
-
-
-
-
- | '''''Non sono presenti procedure di cancellazione.''''' |
- ''Ultimo aggiornamento: 14:00, 9 apr 2018 (CEST)'' |
-
-
-
| '''''Non sono presenti procedure di cancellazione.''''' |
- ''Ultimo aggiornamento: $1%s'' |
+ ''Ultimo aggiornamento: ~~~~~'' |
diff --git a/templates/PAGE_COUNT.entry.closed.tpl b/templates/PAGE_COUNT.entry.closed.tpl
deleted file mode 100644
index 5c5cfcc..0000000
--- a/templates/PAGE_COUNT.entry.closed.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-
-This is the template for a closed entry of the daily counting page.
-
-This template is called multiple time from the "PAGE_COUNT.section.tpl".
-
-Placeholders:
- %1$s: page title
-
-
-[[:Wikipedia:ASD]] closed
-
-
-[[:%1$s]] closed
diff --git a/templates/PAGE_COUNT.entry.multiple_note.tpl b/templates/PAGE_COUNT.entry.multiple_note.tpl
deleted file mode 100644
index 71e0429..0000000
--- a/templates/PAGE_COUNT.entry.multiple_note.tpl
+++ /dev/null
@@ -1,5 +0,0 @@
-
-This is the template for the note that appears to highlight a multiple PDC
-
-
-'''Nota:''' [[Wikipedia:Cancellazioni multiple|procedura di cancellazione multipla]]
diff --git a/templates/PAGE_COUNT.entry.tpl b/templates/PAGE_COUNT.entry.tpl
deleted file mode 100644
index 94c169e..0000000
--- a/templates/PAGE_COUNT.entry.tpl
+++ /dev/null
@@ -1,14 +0,0 @@
-
-This is the template for an entry of the daily counting page.
-
-This template is called multiple time from the "PAGE_COUNT.section.tpl".
-
-Placeholders:
- %1$s: page title
- %2$d: temperature
-
-
-[[:Wikipedia:ASD]] {{Termometro|100}}
-
-
-[[:%1$s]] {{Termometro|%2$d}}
diff --git a/templates/PAGE_COUNT.section.tpl b/templates/PAGE_COUNT.section.tpl
deleted file mode 100644
index 8b2aa28..0000000
--- a/templates/PAGE_COUNT.section.tpl
+++ /dev/null
@@ -1,18 +0,0 @@
-
-This is the template for a section of the daily count page.
-
-This template will call multiple times the "PAGE_COUNT.entry.tpl" template.
-
-Placeholders:
- %1$s: PDC type e.g. 'con votazione'
- %2$s: PDC entries
-
-
-
-{{Wikipedia:Pagine da cancellare/ASD}}
-{{Wikipedia:Pagine da cancellare/DSA}}
-{{Wikipedia:Pagine da cancellare/ASD}}
-
-
-
-%2$s
diff --git a/templates/PAGE_LOG.entry.tpl b/templates/PAGE_LOG.entry.tpl
deleted file mode 100644
index b1cf62f..0000000
--- a/templates/PAGE_LOG.entry.tpl
+++ /dev/null
@@ -1,13 +0,0 @@
-
-This is the template for an entry of the daily log page.
-
-This template is called multiple time from the "PAGE_LOG.section.tpl".
-
-Placeholders:
- %1$s: page title
-
-
-{{Wikipedia:Pagine da cancellare/ASD}}
-
-
-{{%1$s}}
diff --git a/templates/PDC.con_votazione.color.tpl b/templates/PDC.con_votazione.color.tpl
new file mode 100644
index 0000000..0c0dba0
--- /dev/null
+++ b/templates/PDC.con_votazione.color.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the color of a PDC 'con votazione'.
+
+
+#ffe2df
diff --git a/templates/PDC.con_votazione.goto.tpl b/templates/PDC.con_votazione.goto.tpl
new file mode 100644
index 0000000..c794b60
--- /dev/null
+++ b/templates/PDC.con_votazione.goto.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the "vai alla [qualcosa]" action.
+
+This is for a voting PDC.
+
+
+votazione
diff --git a/templates/PDC.consensuale.color.tpl b/templates/PDC.consensuale.color.tpl
new file mode 100644
index 0000000..e68c130
--- /dev/null
+++ b/templates/PDC.consensuale.color.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the color of a PDC 'consensuale'.
+
+
+#ffc
diff --git a/templates/PDC.consensuale.goto.tpl b/templates/PDC.consensuale.goto.tpl
new file mode 100644
index 0000000..ecab17d
--- /dev/null
+++ b/templates/PDC.consensuale.goto.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the "vai alla [qualcosa]" action.
+
+This is for a consensual PDC.
+
+
+discussione
diff --git a/templates/PDC.ordinarie.color.tpl b/templates/PDC.ordinarie.color.tpl
new file mode 100644
index 0000000..b075dff
--- /dev/null
+++ b/templates/PDC.ordinarie.color.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the color of a PDC 'ordinaria'.
+
+
+#ffe2df
diff --git a/templates/PDC.ordinarie.goto.tpl b/templates/PDC.ordinarie.goto.tpl
new file mode 100644
index 0000000..2343833
--- /dev/null
+++ b/templates/PDC.ordinarie.goto.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the "vai alla [qualcosa]" action.
+
+This is for an ordinary PDC.
+
+
+votazione
diff --git a/templates/PDC.prorogate.color.tpl b/templates/PDC.prorogate.color.tpl
new file mode 100644
index 0000000..5983e9e
--- /dev/null
+++ b/templates/PDC.prorogate.color.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the color of a PDC 'consensuale prorogata'.
+
+
+#ffc
diff --git a/templates/PDC.prorogate.goto.tpl b/templates/PDC.prorogate.goto.tpl
new file mode 100644
index 0000000..b5d8f9a
--- /dev/null
+++ b/templates/PDC.prorogate.goto.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the "vai alla [qualcosa]" action.
+
+This is for a prorogated PDC.
+
+
+discussione
diff --git a/templates/PDC.semplificate.color.tpl b/templates/PDC.semplificate.color.tpl
new file mode 100644
index 0000000..6872e2e
--- /dev/null
+++ b/templates/PDC.semplificate.color.tpl
@@ -0,0 +1,5 @@
+
+This is the template for the color of a PDC 'semplificata'.
+
+
+#e5ffe5
diff --git a/templates/PDC.semplificate.goto.tpl b/templates/PDC.semplificate.goto.tpl
new file mode 100644
index 0000000..15396ca
--- /dev/null
+++ b/templates/PDC.semplificate.goto.tpl
@@ -0,0 +1,7 @@
+
+This is the template for the "vai alla [qualcosa]" action.
+
+This is for a semplified PDC.
+
+
+proposta di cancellazione