Skip to content

Commit

Permalink
TASK: Make label configurable from settings
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellienert committed May 22, 2018
1 parent 6bb95c2 commit cb5292c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Classes/AssetSource/MediaWikiAssetProxyQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ public function execute(): AssetProxyQueryResultInterface
*/
public function count(): int
{
throw new \Exception(__METHOD__ . ' is not yet implemented');
throw new \Exception(__METHOD__ . ' is not yet implemented and never used?');
}
}
2 changes: 1 addition & 1 deletion Classes/AssetSource/MediaWikiAssetSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function getIdentifier(): string
*/
public function getLabel(): string
{
return 'Wikipedia';
return $this->getOption('label') ?? $this->getOption('domain');
}

/**
Expand Down
33 changes: 25 additions & 8 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,33 @@
Neos:
Media:
assetSources:
wikipedia:
wikipedia_de:
assetSource: 'DL\AssetSource\MediaWiki\AssetSource\MediaWikiAssetSource'
assetSourceOptions:
domain: en.wikipedia.org
domain: de.wikipedia.org
label: Wikipedia (DE)
searchStrategy: DL\AssetSource\MediaWiki\Api\SearchStrategies\ArticleSearchStrategy
useQueryResultCache: true
excludedIdentifierPatterns:
- '*Wikiquote-logo.svg'
- '*Wikinews-logo.svg'
- '*Commons-logo.svg'
- '*Disambig-dark.svg'
- '*Pictogram voting info.svg'
- '*Loudspeaker.svg'
- '*.svg'
# - '*Wikiquote-logo.svg'
# - '*Wikinews-logo.svg'
# - '*Commons-logo.svg'
# - '*Disambig-dark.svg'
# - '*Pictogram voting info.svg'
# - '*Loudspeaker.svg'
# - '*Speaker_Icon.svg'
# - '*Wikiversity-logo*'
# - '*Wikisource-logo*'
# - '*Wikibooks-logo.svg'
# - '*Wiktionary-logo-v2.svg'
# - '*Wikivoyage-Logo-v3-icon.svg'
# - '*Wiki letter w cropped.svg'
# - '*Openstreetmap_logo.svg'
# - '*Portal-puzzle.svg'
# - '*Question_book-new.svg'
# - '*Translation_to_english_arrow.svg'
# - '*Padlock-silver.svg'
# - '*Searchtool.svg'
# - '*Edit-clear.svg'
# - '*DodgerBlue_flag_waving.svg'
34 changes: 21 additions & 13 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,31 @@ Install the package via composer:

## Configuration

You can add arbitrary instances of this asset source, to query different wikimedia instances - e.g. the english and german instance. To do that, just add another configuration block with the specific settings under a custom identifier.

| setting | Description |
| ------------- |-------------|
| domain | The domain on which the MediaWiki instance is available. |
| label | The label of the instance, shown in the backend |
| searchStrategy | A class with implemented search strategy. See the section below for details |
| excludedIdentifierPatterns | Asset identifiers which should be filtered out and not displayed. Used to filter Wikipedias common icons. |

**Example for accessing the english Wikipedia:**

Neos:
Media:
assetSources:
wikipedia:
assetSource: 'DL\AssetSource\MediaWiki\AssetSource\MediaWikiAssetSource'
assetSourceOptions:
domain: en.wikipedia.org
searchStrategy: DL\AssetSource\MediaWiki\Api\SearchStrategies\ArticleSearchStrategy

| useQueryResultCache | Whether or not to use the result cache for queries to the API. If used, speeds up the pagination a lot but may return outdated results. The caching lifetime defaults to 1 day. |
| excludedIdentifierPatterns | Asset identifiers which should be filtered out and not displayed. Used to filter out Wikipedias common icons. |

**Example for accessing the german Wikipedia:**

Neos:
Media:
assetSources:
wikipedia_de:
assetSource: 'DL\AssetSource\MediaWiki\AssetSource\MediaWikiAssetSource'
assetSourceOptions:
domain: de.wikipedia.org
label: Wikipedia (DE)
searchStrategy: DL\AssetSource\MediaWiki\Api\SearchStrategies\ArticleSearchStrategy
useQueryResultCache: true
excludedIdentifierPatterns:
- '*.svg'
## Search Strategies

Searching in the wikipedia for images is a bit tricky. First there is not only one wikipedia instance, but one for each available language. Second an image can be stored in the language specific wikipedia or in Wikimedia Commons and included from there.
Expand Down

0 comments on commit cb5292c

Please sign in to comment.