diff --git a/README.md b/README.md index ca5da23..0dda040 100644 --- a/README.md +++ b/README.md @@ -1,79 +1,78 @@ # Italian Wikipedia Deletion Bot -This projects aims to handle the public deletion log of Italian Wikipedia pages. +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. {{Citation needed}} +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 :) ## 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, is handled by the [boz-mw](https://github.com/valerio-bozzolan/boz-mw) framework. +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/includes/class-PageYearMonthDayPDCsCount.php b/includes/class-PageYearMonthDayPDCsCount.php index bab5642..6fd817d 100644 --- a/includes/class-PageYearMonthDayPDCsCount.php +++ b/includes/class-PageYearMonthDayPDCsCount.php @@ -1,31 +1,68 @@ . 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(), + ] ); + } + + // 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/PAGE_COUNT.content.tpl b/templates/PAGE_COUNT.content.tpl new file mode 100644 index 0000000..e14ddbb --- /dev/null +++ b/templates/PAGE_COUNT.content.tpl @@ -0,0 +1,25 @@ + +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}}}} + +PDCs...
+ +__NOTOC__ + + +{{#ifexpr:{{#timel:U}}-{{#timel:U|2018-4-20}}<8*24*3600|{{Utente:MauroBot/BotCancellazioni/Avvisi}}}} + +%5$s + +__NOTOC__ diff --git a/templates/PAGE_COUNT.empty.tpl b/templates/PAGE_COUNT.empty.tpl new file mode 100644 index 0000000..f5ad113 --- /dev/null +++ b/templates/PAGE_COUNT.empty.tpl @@ -0,0 +1,21 @@ + +This is the template for an empty daily counting page. + +Placeholders: + %1$s: now timestamp + + + + + + + + + + + + + + + + diff --git a/templates/PAGE_COUNT.entry.closed.tpl b/templates/PAGE_COUNT.entry.closed.tpl new file mode 100644 index 0000000..5c5cfcc --- /dev/null +++ b/templates/PAGE_COUNT.entry.closed.tpl @@ -0,0 +1,13 @@ + +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 new file mode 100644 index 0000000..71e0429 --- /dev/null +++ b/templates/PAGE_COUNT.entry.multiple_note.tpl @@ -0,0 +1,5 @@ + +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 new file mode 100644 index 0000000..94c169e --- /dev/null +++ b/templates/PAGE_COUNT.entry.tpl @@ -0,0 +1,14 @@ + +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 new file mode 100644 index 0000000..8b2aa28 --- /dev/null +++ b/templates/PAGE_COUNT.section.tpl @@ -0,0 +1,18 @@ + +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_COUNT.summary.tpl b/templates/PAGE_COUNT.summary.tpl new file mode 100644 index 0000000..18f4adb --- /dev/null +++ b/templates/PAGE_COUNT.summary.tpl @@ -0,0 +1,16 @@ + +This is the template for the edit summary of a daily log 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 + + +Bot: aggiornamento pagina di servizio giornaliera per i conteggi del 19 aprile 2018 + + +Bot: aggiornamento pagina di servizio giornaliera per i conteggi del %4$d %3$s %1$d diff --git a/templates/PAGE_COUNT.title.tpl b/templates/PAGE_COUNT.title.tpl new file mode 100644 index 0000000..962f325 --- /dev/null +++ b/templates/PAGE_COUNT.title.tpl @@ -0,0 +1,16 @@ + +This is the template for the title 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 + + +Wikipedia:Pagine da cancellare/Conta/2017 aprile 20 + + +Wikipedia:Pagine da cancellare/Conta/%1$d %3$s %4$d