How to show Wikidata sitelink in wikipedia article - mediawiki

I have a local version of Wikipedia and Wikidata running. I would like to have an association between an article and wikidata object in the sidebar like in the standard installation.
But in my version, the field Wikidata item is not shown under Tool in the sitebar. What should I do in order to have that?
Edit:
Added the LocalSetting part. I can also see the toolbox and Addlink, just the wikidata link is not there
# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtensions('ExtensionName');
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
wfLoadExtension( 'Babel' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'CiteThisPage' );
wfLoadExtension( 'ConfirmEdit' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'ImageMap' );
wfLoadExtension( 'Interwiki' );
wfLoadExtension( 'Nuke' );
wfLoadExtension( 'ParserFunctions' );
require_once "$IP/extensions/PdfExport/PdfExport.php";
wfLoadExtension( 'Poem' );
wfLoadExtension( 'Renameuser' );
wfLoadExtension( 'UniversalLanguageSelector' );
require_once "$IP/extensions/Wikibase/Wikibase.php";
wfLoadExtension( 'WikibaseQuality' );
wfLoadExtension( 'WikibaseQualityConstraints' );
wfLoadExtension( 'WikiEditor' );
#wfLoadExtension( 'Mpdf' );
wfLoadExtension( 'TextExtracts' );
#require_once("$IP/extensions/PageSummariesAPI/PageSummariesAPI.php");
# End of automatically generated settings.
# Add more configuration options below.
#Configuration to enable Wikibase client and Repo
$wgEnableWikibaseRepo = true;
$wgEnableWikibaseClient = true;
require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";

This feature is provided by the Wikibase Client MediaWiki extension. You can see that it is added in the extension's source code, where it is added through onBaseTemplateToolbox. According to MediaWiki's documentation, onBaseTemplateToolbox is "Called by BaseTemplate when building the toolbox array and returning it for the skin to output."
The Wikibase Client extension's documentation only mentions the other projects sidebar and I could find no information whether the Wikidata item link is created by default.
From the English Wikipedia's sidebar configuration you can see that the link resides in the TOOLBOX section, which you will need to add to your sidebar if it is not already there.

Related

Does wp_cache still load Wordpress and use MySQL?

I have a JSON API endpoint that uses wp_cache_set/wp_cache_get to store the result. This endpoint is hit hundreds of thousands of times in a day.
However this often takes down my server as it seems the cache is still accessing MySQL and/or loading Wordpress.
Is this true? And if so what would be a better caching solution to make this as light as possible? (eg. memcached)
--
Here's code in case that's helpful:
define('WP_USE_THEMES', false);
require_once('../../../wp-blog-header.php');
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
if(!$image_url) $image_url = $_GET['url'];
if(!$image_url) return false;
$cacheTitle = md5($image_url) . '1';
$result = wp_cache_get( $cacheTitle );
$notCached = $result ? false : true;
if ($notCached){
/** Insert code here to get the data I need and store it in $result **/
wp_cache_set( $cacheTitle, $result );
}
return json_encode($result);
I ended up using Cloudflare Page Rules to cache that specific URL. Clean and easy :)
You're using caching routines within WP that are designed to save you repeating db queries and other expensive operations. So you're saving repeating your md5 but you're still running WP for every page load.
So, yes, to avoid the hit of running WP each time you do need some kind of page cache. Personally I've been using the w3totalcache plugin which has worked well. My next step will likely be a move to Varnish, but there are a few choices out there.

how to deny access to all pages and allow only for certain on wiki

I'm using mediawiki 1.13.3 running on freebsd 7.4
I've got confused with the following task:
how to deny access to All pages for certain users (who has account in my wiki) or for group of these users but allow ReadOnly access for certain pages on wiki.
The goal to achieve is to have no access to pages on wiki except allowed few for some users.
I've tried some extensions but can't find a solution for ~20000 pages and few hundreds of users.
See Manual:Preventing access on mediawiki.org, section "Restrict viewing of all pages".
Specifically, to allow everyone to read (but not edit) the Main Page and a page named Public stuff, and to allow only sysops to read and edit all pages, you'd add the following lines to your LocalSettings.php:
# prevent editing and reading by anons (except for exception listed below):
$wgGroupPermissions['*']['edit'] = false;
$wgGroupPermissions['*']['read'] = false;
# same for normal registered users:
$wgGroupPermissions['user']['edit'] = false;
$wgGroupPermissions['user']['read'] = false;
# allow everyone read access to these pages:
$wgWhitelistRead = array( "Main Page", "Public stuff" );
# allow sysops to read and edit normally:
$wgGroupPermissions['sysop']['edit'] = true;
$wgGroupPermissions['sysop']['read'] = true;
Of course, you can replace sysop above with your own custom user group; I just used it in the example because it exists in a stock MediaWiki install.
(Some older example code suggests also including "Special:UserLogin" and possibly "Special:ChangePassword" and "Special:PasswordReset" in $wgWhitelistRead. In modern MediaWiki versions this should be unnecessary, although still harmless.)
A quite close solution I've found is using simple security extension:
So I'm creating a user group with no access:
$wgGroupPermissions['user']['read'] = false;
add this group to $wgRestrictionLevels = array();
and then restricting read access for some pages to this group.
Fairly enough but not exactly the solution I want to achieve.

Using profile in Watir and Webdriver

My question is regarding modify default profile settings to allow/deny access of mic and cam by my web app. Here is the code - which seems to be ignored.
#!/usr/bin/ruby
require 'watir-webdriver'
profile = Selenium::WebDriver::Chrome::Profile.new
profile['content_settings.pattern_pairs.*,*.media-stream-mic'] = 1
# if I put mysever.com into here (first asterix), the parsing must fail
# as the '.' is used as delimiter by profile.rb - so *,* should work
browser = Watir::Browser.new :chrome, :profile => profile
browser.goto "http://webaudiodemos.appspot.com/input/index.html"
# here a get media event is fired and the browser should proceed without(!)
# asking the user for permission - but the browser is always asking and
# this element is not accessible for Watir (is it?).
I had a look into profile.rb where just the parsing takes place - which is also somehow problematic (see comment inline).
I also searched the web but could not find anything.
Holger
1. create a profile manually using the cmd :
firefox -profilemanager
set what you want on the browser of the new profile
2.code example
protected void initializeWebDriver() {
LoggerInfo.logger.info("Starting webdriver...");
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("MyProfile");
// FirefoxProfile profile = new FirefoxProfile();
driver = new DriverBuilder().using(Browser.FIREFOX).withFirefoxProfile(profile).build();
LoggerInfo.logger.info("webdriver is up");
}

Flash AS3 : Error #1014 : When loading remotely but not locally

Starting with a blank project, when I load a SWF which has a dependence on ISomeInterface defined in a swc which is compiled into my blank project
var lc:LoaderContext = new LoaderContext( true, ApplicationDomain.currentDomain );
var loader:Loader = new Loader();
loader.load( new URLRequest( "Some.swf"), lc );
Not too surpisingly all is good as the interface it requires is already in the application domain into which it has been loaded.
However, when I load the same file from a remote url
loader.load( new URLRequest( "http://127.0.0.1/Some.swf"), lc );
I get the evil
[Fault] exception, information=VerifyError: Error #1014: Class ISomeInterface could
not be found
What am I missing that makes these different?
My issue appears to have been 2 fold
1) When loading the asset locally, it will by default be loaded into the correct security domain. However, when loading from a web site, I need ensure that I set the security domain correctly
new LoaderContext( true, ApplicationDomain.currentDomain, SecurityDomain.currentDomain )
2) However, you can only use the SecurityDomain when the swf you are doing the loading from was actually itself loaded remotely :
Security.sandboxType == Security.REMOTE
So no mix mode of local and remote.
In the end it was a matter of simply loading the first SWF from a website, and adding the correct SecurityDomain.
In my searching, this was the best discorse I found on the topic of Security Domains and Applciation Domains http://www.senocular.com/flash/tutorials/contentdomains/
Since your testing locally you might want to check this out:
http://jansensan.net/flash-player-security-settings-to-develop-locally
Essentially go to the Flash Player security page:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
Click Edit Location -> Add location
Add the project folder or your filesystem root.

How do I save the text in a textarea to the users computer when they click a button in html?

I am working on my blog again, but I want to make an online text editor where you click a button and it saves it to their computer, and if you click the load button it loads a file from their computer. Does anyone know how to do that?
Thanks in Advance!
There is currently no way to write to the filesystem of the client. This is for security reasons.
However, with JavaScript you can store some data (up to 5MB) in the localStorage object and retrieve it from there later on. localStorage #MDN
The localStorage can only store strings in its key-value store, so you might have to serialize your objects before storing them.
Storing
window.localStorage.setItem( 'yourId', JSON.stringfy( yourData ) );
Retrieving
var yourData = JSON.parse( window.localStorage.getItem( 'yourId' ) );
I'm unsure why there is so strong an it's impossible current with client-side storage: all you have to do is export the file as whatever format you want (even plain-text) and have the user download it -- akin to Save As. To load the file, have the user upload it again -- akin to Open.
This can be accomplished by posting the contents of the textarea to a php script, for example.
This is no more steps than using Save As... and Open dialogs in any other local word processing application.
The only reason you might want a user to do this, though, is to allow them to edit the file locally while they were disconnected from your blogging platform. So a more elegant alternative, unless you want the user to actually edit the file locally, is to save draft versions on the server (like StackExchange does).
Loading can be implemented like this in a form (sending to a PHP-script for example):
<input name="usedFile" type="file" class="file" size="50"
accept="text/csv,text/plain" />
This allows for example loading of text- and csv-files.
I think saving is not possible like this.
#comment
It really depends on what you want to do with the file. Here is a simple loading function:
if (!empty($_FILES['usedFile']['tmp_name'])) {
load_uploaded_file($_FILES['usedFile']['tmp_name'], $my_loaded_data);
}
// ...
function load_uploaded_file($filename, &$data) {
if (!file_exists($filename)) {
return False;
}
$data = array();
$rowCount = 0;
$handle = fopen($filename, 'r');
while (($line = fgets($handle, 4096)) !== False) {
$data[$rowCount] = $line;
$rowCount++;
}
fclose($handle);
return True;
}