GithubHelp home page GithubHelp logo

func86 / hybridfilerepo Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 19 KB

Simple MediaWiki FileRepo implementation that serves files locally, but fetch file description from a foreign site.

License: GNU General Public License v2.0

PHP 100.00%

hybridfilerepo's Introduction

Usage

This extension is designed to be used with other foreign file repo extensions.

Example to build a live archive of moegirlpedia with this extension:

wfLoadExtension( 'HybridFileRepo' );
// This must be configured before the foreign repo
$wgForeignFileRepos[] = [
	'class' => MediaWiki\Extension\HybridFileRepo\Repo::class,
	'name' => 'sharedFsRepo',
	'directory' => '/path/to/media', // Fully qualified path to the local directory that contains files
	'hashLevels' => 0,
	'url' => 'http://localhost:8080/w/media', // Change this to your real path
	'foreignRepo' => 'zhmoe', // This should be identical to the name of the foreign file repo below
	'descBaseUrl' => 'https://commons.moegirl.org.cn/File:',
	'fetchDescription' => true,
];

// See also: extension description page on mediawiki.org
wfLoadExtension( 'QuickInstantCommons' );
$wgUseQuickInstantCommons = false;
$wgForeignFileRepos[] = [
	'class' => MediaWiki\Extension\QuickInstantCommons\Repo::class,
	'name' => 'zhmoe', // Must be a distinct name
	'directory' => $wgUploadDirectory, // FileBackend needs some value here.
	'apibase' => 'https://commons.moegirl.org.cn/api.php',
	'hashLevels' => 2, // Important this matches foreign repo if 404 transform enabled.
	'thumbUrl' => 'https://img.moegirl.org.cn/common/thumb', // Set to false to auto-detect
	'fetchDescription' => true, // Optional
	'descriptionCacheExpiry' => 43200, // 12 hours, optional (values are seconds). This cache is not adaptive.
	'transformVia404' => true, // Whether foreign repo supports 404 transform. Much faster if supported
	'abbrvThreshold' => 160, // must match what foreign repo uses if 404 transform enabled. Default is 255. Wikimedia uses 160.
	'apiMetadataExpiry' => 60 * 60 * 24, // Max time metadata is cached for. Recently changed items are cached for less
	'disabledMediaHandlers' => [TiffHandler::class] // media handler extensions to not use. For 404 handling its important that the local media handler extensions match the foreign ones.
];

hybridfilerepo's People

Contributors

func86 avatar

Stargazers

yzqzss avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.