summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/WfextStyle
diff options
context:
space:
mode:
authorYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
committerYaco <franco@reevo.org>2020-06-04 11:01:00 -0300
commitfc7369835258467bf97eb64f184b93691f9a9fd5 (patch)
treedaabd60089d2dd76d9f5fb416b005fbe159c799d /www/wiki/extensions/WfextStyle
first commit
Diffstat (limited to 'www/wiki/extensions/WfextStyle')
-rw-r--r--www/wiki/extensions/WfextStyle/composer.json6
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/de.json7
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/en.json7
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/es.json7
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/fr.json7
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/it.json7
-rw-r--r--www/wiki/extensions/WfextStyle/i18n/pt.json7
-rw-r--r--www/wiki/extensions/WfextStyle/images/msu-3D.pngbin0 -> 1905 bytes
-rw-r--r--www/wiki/extensions/WfextStyle/images/msu-play-verysmall.pngbin0 -> 1893 bytes
-rw-r--r--www/wiki/extensions/WfextStyle/maintenance/generateThumbsImages.php152
-rw-r--r--www/wiki/extensions/WfextStyle/templates/layout-group-search-result.html21
-rw-r--r--www/wiki/extensions/WfextStyle/templates/print-footer.html36
-rw-r--r--www/wiki/extensions/WfextStyle/wikifab-style.css40
-rw-r--r--www/wiki/extensions/WfextStyle/wikifab-style.js101
-rw-r--r--www/wiki/extensions/WfextStyle/wikifabstyle.php85
15 files changed, 483 insertions, 0 deletions
diff --git a/www/wiki/extensions/WfextStyle/composer.json b/www/wiki/extensions/WfextStyle/composer.json
new file mode 100644
index 00000000..3d1c21f4
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/composer.json
@@ -0,0 +1,6 @@
+{
+ "name": "wikifab/wfext-style",
+ "type": "mediawiki-extension",
+ "require": {
+ }
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/de.json b/www/wiki/extensions/WfextStyle/i18n/de.json
new file mode 100644
index 00000000..bc12cf6c
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/de.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "Anpassung des Stils für Wikifab",
+ "wfextstyle-my_profil": "Mein Profil"
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/en.json b/www/wiki/extensions/WfextStyle/i18n/en.json
new file mode 100644
index 00000000..ec79e4e2
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/en.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "Style customization for wikifab",
+ "wfextstyle-my_profil": "My Profile"
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/es.json b/www/wiki/extensions/WfextStyle/i18n/es.json
new file mode 100644
index 00000000..456ab96d
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/es.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "personalizar el estilo de wikifab",
+ "wfextstyle-my_profil": "Mi perfil"
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/fr.json b/www/wiki/extensions/WfextStyle/i18n/fr.json
new file mode 100644
index 00000000..4b4cb400
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/fr.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "customisation du style pour wikifab",
+ "wfextstyle-my_profil": "Mon Profil"
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/it.json b/www/wiki/extensions/WfextStyle/i18n/it.json
new file mode 100644
index 00000000..0856f3b5
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/it.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "personalizzazione dello stile per wikifab",
+ "wfextstyle-my_profil": "il mio profilo"
+}
diff --git a/www/wiki/extensions/WfextStyle/i18n/pt.json b/www/wiki/extensions/WfextStyle/i18n/pt.json
new file mode 100644
index 00000000..c3aa9b9a
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/i18n/pt.json
@@ -0,0 +1,7 @@
+{
+ "@metadata": {
+ "authors": ["Pierre Boutet"]
+ },
+ "wfextstyle-desc": "personalização do estilo para wikifab",
+ "wfextstyle-my_profil": "O meu perfil"
+}
diff --git a/www/wiki/extensions/WfextStyle/images/msu-3D.png b/www/wiki/extensions/WfextStyle/images/msu-3D.png
new file mode 100644
index 00000000..c4fa5735
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/images/msu-3D.png
Binary files differ
diff --git a/www/wiki/extensions/WfextStyle/images/msu-play-verysmall.png b/www/wiki/extensions/WfextStyle/images/msu-play-verysmall.png
new file mode 100644
index 00000000..22414197
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/images/msu-play-verysmall.png
Binary files differ
diff --git a/www/wiki/extensions/WfextStyle/maintenance/generateThumbsImages.php b/www/wiki/extensions/WfextStyle/maintenance/generateThumbsImages.php
new file mode 100644
index 00000000..62260bbf
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/maintenance/generateThumbsImages.php
@@ -0,0 +1,152 @@
+<?php
+/**
+ * Run pending jobs.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ * @file
+ * @ingroup Maintenance
+ */
+
+require_once __DIR__ . '/../../../maintenance/Maintenance.php';
+
+/**
+ * Maintenance script that runs pending jobs.
+ *
+ * @ingroup Maintenance
+ */
+class GenerateThumbsImages extends Maintenance {
+
+ protected $sizes = [];
+
+ public function __construct() {
+ parent::__construct();
+ $this->addDescription( 'Run pending jobs' );
+ $this->addOption( 'reallyRun', 'if not set, this will only show what it would have done', false, false );
+ $this->addOption( 'maxThumbs', 'Maximum number of thumbs to generat', false, true );
+ $this->addOption( 'maxTime', 'Maximum amount of wall-clock time', false, true );
+ $this->addOption( 'startName', 'imageNameToStart', false, true );
+ $this->addOption( 'lastMin', 'number of min for select recents pictures only ', false, true );
+ }
+
+ public function execute() {
+ global $wgCommandLineMode, $wgThumbLimits;
+
+ $this->sizes = $wgThumbLimits;
+
+
+ $reallyRun = $this->hasOption( 'reallyRun' );
+
+ $maxThumbs = $this->getOption( 'maxThumbs', false );
+ $maxTime = $this->getOption( 'maxTime', false );
+
+ $this->output("Really run : $reallyRun \n");
+ $this->output("Really maxThumbs : $maxThumbs \n");
+
+
+ // look for all files :
+ $titles =[];
+
+ $this->mBatchSize = 20;
+ $lastName = $this->getOption( 'startName', '' );
+ $lastMin = $this->getOption( 'lastMin', '' );
+
+ $conds = [];
+
+ $count = 0;
+ $startTime = wfTimestampNow();
+
+ $repo = RepoGroup::singleton()->getLocalRepo();
+ //$repo->enumFiles( ['GenerateThumbsImages', 'generateThumbsImagesCallBack'] ) ;
+ $dbw = $repo->getMasterDB ();
+
+ if ($lastMin) {
+ $lastMinTimestamp = date("YmdH0000", strtotime("-" . $lastMin . " minutes"));
+ $this->output( "timestamp : $lastMinTimestamp \n" );
+ $conds[] = 'img_timestamp >= ' .$lastMinTimestamp;
+ }
+
+ $totalCount = $dbw->estimateRowCount('image', $vars = '*', $conds);
+ $this->output( "Nb image to check : $totalCount \n" );
+
+ do {
+ $res = $dbw->select ( 'image',
+ array ('img_name', 'img_sha1'),
+ array_merge ( array ('img_name > ' . $dbw->addQuotes ( $lastName )), $conds ),
+ __METHOD__,
+ array (
+ 'LIMIT' => $this->mBatchSize,
+ 'ORDER BY' => 'img_name'
+ )
+ );
+ foreach ( $res as $row ) {
+ $lastName = $row->img_name;
+ $sha1 = $row->img_sha1;
+ if (! strlen ( $sha1 )) {
+ $this->error ( "Image SHA-1 not set for {$row->img_name}." );
+ } else {
+ $file = $repo->newFile ( $row->img_name );
+ $this->generateAllThumbs($file, $reallyRun);
+
+ }
+ }
+ $count += $res->numRows ();
+ if ($maxThumbs && $count >= $maxThumbs ) {
+ break;
+ }
+ $this->output( "processing images $count/$totalCount \n" );
+ } while ( $res->numRows () );
+ }
+
+ public function generateAllThumbs(File $file, $really) {
+
+ foreach ($this->sizes as $size) {
+
+
+ $thumbName = $file->thumbName( ['width' => $size] );
+ $thumbPath = $file->getThumbPath( $thumbName );
+ //echo '<br/>';
+ $exist = $file->getRepo()->fileExists( $thumbPath );
+ if ( !$exist ) {
+ $transformParams = ["width" => $size ];
+ $thumb = $file->transform( $transformParams,File::RENDER_NOW);
+
+ if ( $thumb && !$thumb->isError()) {
+ $result = True;
+ } else {
+ $result = 'fail';
+ }
+ $this->output("generate Thumb size ". $size ." file :" . $file->getName() . " result : $result\n");
+ } else {
+ $this->output("existing Thumb size ". $size ." file :" . $file->getName() . " \n");
+ }
+ }
+ }
+
+ protected function getRepo() {
+ return RepoGroup::singleton()->getLocalRepo();
+ }
+
+ /**
+ * @param string $s
+ */
+ public function debugInternal( $s ) {
+ $this->output( $s );
+ }
+}
+
+$maintClass = "GenerateThumbsImages";
+require_once RUN_MAINTENANCE_IF_MAIN;
diff --git a/www/wiki/extensions/WfextStyle/templates/layout-group-search-result.html b/www/wiki/extensions/WfextStyle/templates/layout-group-search-result.html
new file mode 100644
index 00000000..62e06f10
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/templates/layout-group-search-result.html
@@ -0,0 +1,21 @@
+<div class="col-md-6 col-sm-6 col-xs-12">
+ <div class="project-card">
+ <a href="{{url}}">
+ <div class="row">
+ <div class="col-md-3 col-sm-4 col-xs-4">
+ <div class="group-thumbnail"><img src="{{group-logo::url}}" alt="{{title}}"/></div>
+ </div>
+ <div class="col-md-9 col-sm-8 col-xs-8">
+ <div class="group-card-content">
+
+ <h5 class="group-title">
+ <span class="mw-headline">{{title}}</span>
+ </h5>
+ <p class="group-byline">{{int:group-type}} </p>
+ <p class="group-blurb">{{group-description}}</p>
+ </div>
+ </div>
+ </div>
+ </a>
+ </div>
+</div> \ No newline at end of file
diff --git a/www/wiki/extensions/WfextStyle/templates/print-footer.html b/www/wiki/extensions/WfextStyle/templates/print-footer.html
new file mode 100644
index 00000000..0b311b5b
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/templates/print-footer.html
@@ -0,0 +1,36 @@
+<!doctype html>
+<html>
+<head><script>
+function subst() {
+ var vars={};
+ var x=document.location.search.substring(1).split('&');
+ for (var i in x) {var z=x[i].split('=',2);vars[z[0]] = unescape(z[1]);}
+ var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
+ for (var i in x) {
+ var y = document.getElementsByClassName(x[i]);
+ for (var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
+ }
+
+ var notonfirstpage = document.getElementsByClassName('not-on-first-page');
+ for (var j=0; j<notonfirstpage.length; ++j) {
+ if(vars['page'] == 1) {
+ notonfirstpage[j].parentNode.removeChild(notonfirstpage[j]);
+ }
+ }
+}
+</script>
+ <meta charset="utf-8">
+ <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,600,800,400italic,600italic,700italic,800italic,300,300italic' rel='stylesheet' type='text/css'>
+ </head>
+ <body id="pdf-footer" onload="subst()" style="font-family:Helvetica Neue,Helvetica,Arial,sans-serif;font-size:14px;">
+ <footer>
+ <div style="width:100%;border-bottom:1px solid #eeeeee;margin-bottom:0.5em;"></div>
+ <table style="width:100%">
+ <tr>
+ <td>wikifab.org</td>
+ <td style="text-align:right;">Page <span class="page"></span> / <span class="topage"></span></td>
+ </tr>
+ </table>
+ </footer>
+ </body>
+</html> \ No newline at end of file
diff --git a/www/wiki/extensions/WfextStyle/wikifab-style.css b/www/wiki/extensions/WfextStyle/wikifab-style.css
new file mode 100644
index 00000000..40d34eb7
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/wikifab-style.css
@@ -0,0 +1,40 @@
+div.file-3D,
+div.videofile{
+ position: relative;
+ width: 100%;
+ height: 100%;
+}
+
+div.file-3D .stl-file{
+ background-image: url(images/msu-3D.png);
+ background-repeat: no-repeat;
+ width: 100%;
+ height: 100%;
+ display: block;
+ position: absolute;
+ margin: 5px;
+ background-position: 0 0;
+}
+
+div.videofile .mp4-file{
+ background-image: url(images/msu-play-verysmall.png);
+ background-position: center;
+ background-repeat: no-repeat;
+ width: 100%;
+ height: 100%;
+ display: block;
+ position: absolute;
+ padding: 5px;
+}
+
+.carousel-thumb .stl-file{
+ background-size: 38px;
+}
+
+.item .stl-file{
+ background-size: auto;
+}
+
+.item .mp4-file{
+ display: none;
+} \ No newline at end of file
diff --git a/www/wiki/extensions/WfextStyle/wikifab-style.js b/www/wiki/extensions/WfextStyle/wikifab-style.js
new file mode 100644
index 00000000..809ddaf1
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/wikifab-style.js
@@ -0,0 +1,101 @@
+
+/*
+$( document ).ready(function() {
+ $(window).scroll(function(){
+ // en haut :
+ //$("#saving-menu").css("top",Math.max(0,250-$(this).scrollTop()));
+
+ $originalPosition = Math.floor($('.footer-main').position().top - $(this).scrollTop());
+
+ $movedPosition = $(this).height() - $('.saving-menu').outerHeight(true) ;
+
+ // en bas :position:fixed
+ if($originalPosition < $movedPosition) {
+ $(".saving-menu").css("position",'relative');
+ $(".saving-menu").css("top","");
+ $(".saving-menu").css("margin-left",0);
+ } else {
+ $(".saving-menu").css("position",'fixed');
+ $(".saving-menu").css("top",$movedPosition);
+ $(".saving-menu").css("margin-left",$("body").css("margin-left"));
+ }
+ });
+});*/
+
+$( document ).ready(function() {
+ $('.file-3D').wrap("<div class='file-3D'></div>");
+ $('<span>').addClass('stl-file').prependTo('div.file-3D');
+
+ $('.videofile').wrap("<div class='videofile'></div>");
+ $('<span>').addClass('mp4-file').prependTo('div.videofile');
+});
+
+// BACK TO TOP
+
+// When the user scrolls down 20px from the top of the document, show the button
+window.onscroll = function() {scrollFunction()};
+
+function scrollFunction() {
+ if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
+ document.getElementById("backToTop").style.display = "block";
+ } else {
+ document.getElementById("backToTop").style.display = "none";
+ }
+}
+
+// When the user clicks on the button, scroll to the top of the document
+function topFunction() {
+ $('body, html').stop().animate({scrollTop:0}, 500, 'swing', function() {
+ });
+}
+
+// BACK TO TOP - END
+
+
+// SMOOTH SCROLLING PAGE ANCHOR
+
+$(function() {
+ /**
+ * Smooth scrolling to page anchor on click
+ **/
+ $(".smooth-scroll a[href*='#']:not([href='#'])").click(function() {
+ if (
+ location.hostname == this.hostname
+ && this.pathname.replace(/^\//,"") == location.pathname.replace(/^\//,"")
+ ) {
+ var anchor = $(this.hash);
+ anchor = anchor.length ? anchor : $("[name=" + this.hash.slice(1) +"]");
+ if ( anchor.length ) {
+ $("html, body").animate( { scrollTop: anchor.offset().top }, 800);
+ }
+ }
+ });
+});
+
+// SMOOTH SCROLLING PAGE ANCHOR - END
+
+// LOGIN POPUP ON CLICK ON EDIT BUTTON (Not logged in)
+
+(function() {
+ $( document ).ready(function() {
+ $('#ca-edit a, #ca-formedit a').click(function(e){
+ if (! mw.config.get('wgUserId')) {
+ e.preventDefault();
+ displayModal();
+ return;
+ }
+ });
+ });
+
+ function displayModal() {
+ $( "#connectionRequiredModal" ).modal();
+ }
+})();
+
+// LOGIN POPUP ON CLICK ON EDIT BUTTON - END
+
+
+$('body').on('click.collapse-next.data-api', '[data-toggle=collapse-next]', function (e) {
+ var $target = $(this).next(".collapse");
+ $target.data('bs.collapse') ? $target.collapse('toggle') : $target.collapse();
+})
diff --git a/www/wiki/extensions/WfextStyle/wikifabstyle.php b/www/wiki/extensions/WfextStyle/wikifabstyle.php
new file mode 100644
index 00000000..c9a30180
--- /dev/null
+++ b/www/wiki/extensions/WfextStyle/wikifabstyle.php
@@ -0,0 +1,85 @@
+<?php
+
+$wgMessagesDirs['WfExtStyle'] = __DIR__ . "/i18n";
+
+$wgResourceModules['ext.Wikifab.js'] = array(
+ 'scripts' => 'wikifab-style.js',
+ 'styles' => array(),
+ 'messages' => array(
+ ),
+ 'dependencies' => array(
+ 'jquery.ui.core'
+ ),
+ 'position' => 'bottom',
+ 'localBasePath' => __DIR__ . '',
+ 'remoteExtPath' => 'WfextStyle',
+);
+
+$wgResourceModules['ext.Wikifab.css'] = array(
+ 'styles' => array(
+ 'wikifab-style.css',
+ ),
+ 'localBasePath' => __DIR__,
+ 'remoteExtPath' => 'WfextStyle',
+);
+
+// Specify the function that will change the user menu.
+$wgHooks['PersonalUrls'][] = 'PersonalUrlsWikifabCustom';
+function PersonalUrlsWikifabCustom( &$personal_urls, &$title, $that ) {
+ unset($personal_urls['mytalk']);
+ if(isset($personal_urls['userpage']['text'])) {
+ $personal_urls['userpage']['text'] = wfMessage( 'wfextstyle-my_profil');
+ }
+ if(isset($personal_urls['anonuserpage'])) {
+ unset($personal_urls['anonuserpage']);
+ }
+ if(isset($personal_urls['anontalk'])) {
+ unset($personal_urls['anontalk']);
+ }
+ if(isset($personal_urls['watchlist'])) {
+ unset($personal_urls['watchlist']);
+ }
+ if(isset($personal_urls['mycontris'])) {
+ unset($personal_urls['mycontris']);
+ }
+}
+
+$wgWikifabStyleForceUpdate = true;
+
+// hook to launch synchronous update properties of new pages
+// this has been added because if not, after create new page,
+// the page has not instantly his properties, and so the forms links (action=formedit) are not setted
+$wgHooks['ArticleEditUpdates'][] = 'wfExtStyleArticleEditUpdates';
+function wfExtStyleArticleEditUpdates( WikiPage $wikipage, $editInfo, $changed ) {
+ global $wgWikifabStyleForceUpdate;
+ if ($wgWikifabStyleForceUpdate) {
+ $title = $wikipage->getTitle();
+ $output = $editInfo->output;
+
+ if( ! $editInfo->oldContent ) {
+ $linksUpdate = new LinksUpdate( $title, $output, $recursive = false );
+ $linksUpdate->doUpdate();
+ }
+ }
+}
+
+
+$wgHooks['ParserMakeImageParams'][] = 'onParserMakeImageParams';
+function onParserMakeImageParams( $title, $file, &$params, $parser ) {
+ if(method_exists($file, 'getMimeType')){
+ switch ($file->getMimeType()) {
+ case 'application/sla':
+ $params['frame']['class'] = 'file-3D';
+ break;
+ case 'video/mp4':
+ $params['frame']['class'] = 'videofile';
+ break;
+ }
+ }
+ return true;
+}
+
+$wgHooks['BeforePageDisplay'][] = 'onBeforePageDisplay';
+function onBeforePageDisplay( OutputPage &$out, Skin &$skin ) {
+ $out->addModuleStyles('ext.Wikifab.css');
+}