Jump to content

Extension:YJShopping

From mediawiki.org
MediaWiki extensions manual
YJShopping
Release status: stable
Implementation Tag
Description generate item link via Yahoo! JAPAN API
Author(s) Kimagurenote (Corytalk)
Latest version 1.3.3
MediaWiki
PHP 5.4.0+
Database changes No
‎<yjshopping>
Licence BSD 3-clause "Modified" License
Download https://kimagurenote.net/kn/YJShopping#Download
https://kimagurenote.net/kn/YJShopping#History
Example https://kimagurenote.net/kn/YJShopping#%E8%A8%98%E8%BF%B0%E4%BE%8B_Usage

The YJShopping extension provides a way to embed shopping link for some shopping sites via Yahoo! JAPAN Item Search API into wiki pages.

Installation

[edit]
  • At first, you must get Yahoo! JAPAN API ID (Japanese).
  • You can use some affiliate program. You must get those IDs from ValueCommerce, LinkShare, Amazon Associates and Rakuten Affilate if you want to use.
  • Download zip file from author's website, unzip it and place the file(s) in a directory called YJShopping in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    /* Extension:YJShopping */
    require_once "$IP/extensions/YJShopping/YJShopping.php";
    $wgYJShoppingAppID = '★';
    $wgYJShoppingPlus['yahoo']['sid'] = '※';
    $wgYJShoppingPlus['yahoo']['pid'] = '※';
    $wgYJShoppingPlus['amazon'] = '◆';
    #$wgYJShoppingPlus['amazon']['sid'] = '※';
    #$wgYJShoppingPlus['amazon']['pid'] = '※';
    $wgYJShoppingPlus['rakuten'] = '▲';
    #$wgYJShoppingPlus['rakuten']['lsid'] = '●';
    #$wgYJShoppingPlus['rakuten']['sid'] = '※';
    #$wgYJShoppingPlus['rakuten']['pid'] = '※';
    $wgYJShoppingPlus['sofmap']['lsid'] = '●';
    $wgYJShoppingPlus['sofmapused']['lsid'] = '●';
    $wgYJShoppingPlus['naturum']['lsid'] = '●';
    $wgYJShoppingPlus['honto']['sid'] = '※';
    $wgYJShoppingPlus['honto']['pid'] = '※';
    $wgYJShoppingPlus['7net']['sid'] = '※';
    $wgYJShoppingPlus['7net']['pid'] = '※';
    $wgYJShoppingPlus['wowma']['lsid'] = '●';
    $wgYJShoppingPlus['nttxstore']['a8mat'] = '△';
    $wgYJShoppingPlus['qoo10']['sid'] = '※';
    $wgYJShoppingPlus['qoo10']['pid'] = '※';
    $wgYJShoppingPlus['anker']['sid'] = '※';
    $wgYJShoppingPlus['anker']['pid'] = '※';
    $wgYJShoppingPlus['mercari'] = '☆';
    $wgYJShoppingPlus['kakakucom'] = true;
    
    /* (option) */
    $wgYJShoppingDefaultButtons = [ 'yahoo', 'amazon', 'rakuten', 'mercari' ];
    $wgYJShoppingBookButtons = [ 'yahoo', 'amazon', 'rakuten', 'honto', 'ebookjapan', '7net', 'mercari' ];
    $wgYJShoppingMatchAddbtn = [ "anker" => "anker wowma" ];
    
    /* (option) Link target */
    $wgYJShoppingTarget = '_blank';
    
    /* (option) Lazy loading */
    $wgNativeImageLazyLoading = true;
    
    /* (option) Caching */
    $wgYJShoppingCaching = true;
    $wgYJShoppingCachingTime = 43200;
    
  • Add the following code at the bottom of your MediaWiki:Common.css. You can fully customize it. But you will need some permissions if you use MediaWiki 1.32 or above. See: MediaWiki_1.32/interface-admin.
/* Extension:YJShopping */
DIV.yjshopping {
	clear: both;
	width: 100%;
	min-height: 180px;
	margin: 0 auto;
	padding: 0.5em;
	border: 1px solid #444;
	overflow: hidden;
}
DIV.yjshopping IMG.yjshoppingimg {
	float: left;
	margin: 0.1em 1em 0.1em 0.1em;
}
DIV.yjshopping P.yjshoppingname {
	margin: 0;
	font-size: 90%;
	text-indent: 0;
}
DIV.yjshopping P.yjshoppingstore::before {
	background-color: #bbb;
	border-radius: 10%;
	color: #fff;
	font-size: smaller;
	padding: 0 0.5em 0 0.5em;
	margin-right: 0.5em;
	content: "Ad";
}
DIV.yjshopping P.yjshoppingstore {
	margin: 0;
	font-size: 80%;
	text-indent: 0;
}
DIV.yjshopping UL {
	margin: 0;
}
DIV.yjshopping UL LI {
	display: inline-block;
	text-align: center;
	list-style: none;
	font-size: 85%;
	width: 10em;
	margin: 0.2em;
	padding: 0.2em 0.5em 0.2em 0.5em;
	border-radius: 0.5em;
	white-space: nowrap;
}
DIV.yjshopping UL LI A {
	color: #fff;
}
P.yjshoppingsearchtext {
	margin: 0.2em 0 0.5em 1em;
	font-weight: bold;
}
DIV.yjshopping UL LI.shoplinkyahoo {
	background-color: #f55;
}
DIV.yjshopping UL LI.shoplinkamazon {
	background-color: #f90;
}
DIV.yjshopping UL LI.shoplinkrakuten {
	background-color: #c00;
}
DIV.yjshopping UL LI.shoplinksofmap {
	background-color: #16f;
}
DIV.yjshopping UL LI.shoplinksofmapused {
	background-color: #3ba;
}
DIV.yjshopping UL LI.shoplinknaturum {
	background-color: #084;
}
DIV.yjshopping UL LI.shoplinkhonto {
	background-color: #4af;
}
DIV.yjshopping UL LI.shoplink7net {
	background-color: #153;
}
DIV.yjshopping UL LI.shoplinkwowma {
	background-color: #f71;
}
DIV.yjshopping UL LI.shoplinknttxstore {
	background-color: #06a;
}
DIV.yjshopping UL LI.shoplinkqoo10 {
	background-color: #5af;
}
DIV.yjshopping UL LI.shoplinkanker {
	background-color: #2ae;
}
DIV.yjshopping UL LI.shoplinkmercari {
	background-color: #f00;
}
DIV.yjshopping UL LI.shoplinkkakakucom {
	background-color: #02d;
}
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Usage

[edit]
<yjshopping>search keyword(s)</yjshopping>

Put item links about "fruits". For example:

<yjshopping>fruits</yjshopping>

Put book links about "MediaWiki". For example:

<yjshopping querytype="book">MediaWiki</yjshopping>

Put item links about "Type-C charger" sell from AnkerDirect and addbtn to Anker. (v1.3.0+) For example:

<yjshopping seller_id="ankerdirect" addbtn="anker">Type-C charger</yjshopping>

You can specify some parameters(*). For example:

<yjshopping genre_category_id="10604">MediaWiki</yjshopping>

(*) Details see here (Japanese).

You can set ISBN or JAN(EAN) code directly. For example:

<yjshopping querytype="isbn">978-4-04-072421-8</yjshopping>
<yjshopping querytype="jan">4988003561802</yjshopping>

If you get no result, this extension met some error(s) to call API.

Additional Settings

[edit]

Caching

[edit]

(1.2.7+) This extension is able to cache search results by MediaWiki object cache.

This feature will save to call API, resulting faster and reducing errors.

You can set live time of cached data as seconds, 3600 seconds (1 hour) by default.

$wgYJShoppingCaching = true;
$wgYJShoppingCachingTime = 43200;

(1.3.3+) This extension uses MainStash to improve response if available.

Note: This extension uses MediaWiki ObjectCache mechanism. You must configure $wgMainCacheType and $wgMainStash if already not.

Note: This is a different feature from parser cache (setting). Purge not affect this feature.

Note: You can't clear this cache individually. You can set caching alive time as $wgYJShoppingCachingTime at your's discretion, but we recommend to set 86400 (1 day) or shorter.

Without API mode

[edit]

(1.3.3+) This feature is showing simply links without item image if meets API error.

This extension put no result if meets API errors if this feature not active.

$wgYJShoppingShowLinksWithoutAPI = true;

Note: This feature will not work with "No Operation".

No Operation

[edit]

(1.3.3+) You can pause this function temporally when API failure and so on.

$wgYJShoppingNoOperation = true;

Note: "Without API mode" will not work with this feature.

Notice

[edit]

Yahoo! JAPAN shopping search API v3 available only in Japan.

Additional information please see author's site (written in Japanese).

See also

[edit]