From fc7369835258467bf97eb64f184b93691f9a9fd5 Mon Sep 17 00:00:00 2001 From: Yaco Date: Thu, 4 Jun 2020 11:01:00 -0300 Subject: first commit --- www/wiki/extensions/WfextStyle/composer.json | 6 + www/wiki/extensions/WfextStyle/i18n/de.json | 7 + www/wiki/extensions/WfextStyle/i18n/en.json | 7 + www/wiki/extensions/WfextStyle/i18n/es.json | 7 + www/wiki/extensions/WfextStyle/i18n/fr.json | 7 + www/wiki/extensions/WfextStyle/i18n/it.json | 7 + www/wiki/extensions/WfextStyle/i18n/pt.json | 7 + www/wiki/extensions/WfextStyle/images/msu-3D.png | Bin 0 -> 1905 bytes .../WfextStyle/images/msu-play-verysmall.png | Bin 0 -> 1893 bytes .../maintenance/generateThumbsImages.php | 152 +++++++++++++++++++++ .../templates/layout-group-search-result.html | 21 +++ .../WfextStyle/templates/print-footer.html | 36 +++++ www/wiki/extensions/WfextStyle/wikifab-style.css | 40 ++++++ www/wiki/extensions/WfextStyle/wikifab-style.js | 101 ++++++++++++++ www/wiki/extensions/WfextStyle/wikifabstyle.php | 85 ++++++++++++ 15 files changed, 483 insertions(+) create mode 100644 www/wiki/extensions/WfextStyle/composer.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/de.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/en.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/es.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/fr.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/it.json create mode 100644 www/wiki/extensions/WfextStyle/i18n/pt.json create mode 100644 www/wiki/extensions/WfextStyle/images/msu-3D.png create mode 100644 www/wiki/extensions/WfextStyle/images/msu-play-verysmall.png create mode 100644 www/wiki/extensions/WfextStyle/maintenance/generateThumbsImages.php create mode 100644 www/wiki/extensions/WfextStyle/templates/layout-group-search-result.html create mode 100644 www/wiki/extensions/WfextStyle/templates/print-footer.html create mode 100644 www/wiki/extensions/WfextStyle/wikifab-style.css create mode 100644 www/wiki/extensions/WfextStyle/wikifab-style.js create mode 100644 www/wiki/extensions/WfextStyle/wikifabstyle.php (limited to 'www/wiki/extensions/WfextStyle') 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 Binary files /dev/null and b/www/wiki/extensions/WfextStyle/images/msu-3D.png 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 Binary files /dev/null and b/www/wiki/extensions/WfextStyle/images/msu-play-verysmall.png 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 @@ +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 '
'; + $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 @@ +
+ +
\ 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 @@ + + + + + + + + + + \ 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("
"); + $('').addClass('stl-file').prependTo('div.file-3D'); + + $('.videofile').wrap("
"); + $('').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 @@ + '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'); +} -- cgit v1.2.1