jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/383049 )
Change subject: Use global config everywhere
......................................................................
Use global config everywhere
* Ensure config is loaded before all other code
* Do not use any hardcoded URL values outside of config
* Minor optimization for localhost debugging
Change-Id: I933162c48aaddb121062a1e39e484ed2f4c9ece8
---
M embed.html
M index.html
M wikibase/config.js
M wikibase/init.js
4 files changed, 31 insertions(+), 24 deletions(-)
Approvals:
Smalyshev: Looks good to me, approved
jenkins-bot: Verified
diff --git a/embed.html b/embed.html
index 553a14b..840738d 100644
--- a/embed.html
+++ b/embed.html
@@ -192,6 +192,7 @@
<!-- endbuild -->
<!-- build:js js/embed.wdqs.min.js -->
+ <script src="wikibase/config.js"></script>
<script src="wikibase/queryService/ui/ResultView.js"></script>
<script
src="wikibase/queryService/ui/resultBrowser/helper/FormatterHelper.js"></script>
<script
src="wikibase/queryService/ui/resultBrowser/AbstractResultBrowser.js"></script>
@@ -221,7 +222,6 @@
<script
src="wikibase/queryService/ui/queryHelper/SelectorBox.js"></script>
<script
src="wikibase/queryService/ui/queryHelper/QueryTemplate.js"></script>
<script src="wikibase/queryService/ui/toolbar/ActionBar.js"></script>
- <script src="wikibase/config.js"></script>
<!-- endbuild -->
<script type="text/javascript">
diff --git a/index.html b/index.html
index 946a003..4202608 100644
--- a/index.html
+++ b/index.html
@@ -101,6 +101,7 @@
</nav>
<div id="query-box">
+ <!-- The action URL is also set dynamically
inside wikibase/init.js -->
<form id="query-form"
action="https://query.wikidata.org/bigdata/namespace/wdq/sparql">
<div class="query-main">
<div class="toolbar">
@@ -322,6 +323,7 @@
<!-- endbuild -->
<!-- build:js js/wdqs.min.js -->
+ <script src="wikibase/config.js"></script>
<script src="wikibase/queryService/ui/App.js"></script>
<script src="wikibase/queryService/ui/toolbar/ActionBar.js"></script>
<script
src="wikibase/queryService/ui/i18n/LanguageSelector.js"></script>
@@ -359,7 +361,6 @@
<script src="wikibase/queryService/api/Wikibase.js"></script>
<script src="wikibase/queryService/api/Tracking.js"></script>
<script src="wikibase/queryService/RdfNamespaces.js"></script>
- <script src="wikibase/config.js"></script>
<script src="wikibase/init.js"></script>
<!-- endbuild -->
</body>
diff --git a/wikibase/config.js b/wikibase/config.js
index 1911906..427c9a6 100644
--- a/wikibase/config.js
+++ b/wikibase/config.js
@@ -14,6 +14,8 @@
return null;
}
+ var root = 'https://query.wikidata.org/';
+
var configDeploy = {
language: getUserLanguage() || 'en',
api: {
@@ -40,34 +42,37 @@
title: 'Wikidata Query'
},
location: {
- index: 'https://query.wikidata.org/'
+ root: root,
+ index: root
}
};
-
- var configLocal = $.extend( true, {}, configDeploy, {
- api: {
- sparql: {
- uri:
'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
- }
- },
- i18nLoad: function( lang ) {
- return $.when(
- $.i18n().load( 'i18n/' + lang +
'.json', lang ),
- $.i18n().load(
'node_modules/jquery.uls/i18n/' + lang + '.json', lang )
- );
- },
- brand: {
- title: 'Localhost'
- },
- location: {
- index: './index.html'
- }
- } );
var hostname = window.location.hostname.toLowerCase();
if ( hostname === '' || hostname === 'localhost' || hostname ===
'127.0.0.1' ) {
- return configLocal;
+
+ // Override for local debugging
+ return $.extend( true, {}, configDeploy, {
+ api: {
+ sparql: {
+ uri:
'https://query.wikidata.org/bigdata/namespace/wdq/sparql'
+
+ }
+ },
+ i18nLoad: function( lang ) {
+ return $.when(
+ $.i18n().load( 'i18n/' + lang +
'.json', lang ),
+ $.i18n().load(
'node_modules/jquery.uls/i18n/' + lang + '.json', lang )
+ );
+ },
+ brand: {
+ title: 'Localhost'
+ },
+ location: {
+ root: './',
+ index: './index.html'
+ }
+ } );
}
return configDeploy;
diff --git a/wikibase/init.js b/wikibase/init.js
index f6a9650..58b9330 100644
--- a/wikibase/init.js
+++ b/wikibase/init.js
@@ -29,6 +29,7 @@
function() {
setBrand();
+ $( '#query-form' ).attr( 'action',
config.api.sparql.uri );
var lang = Cookies.get( 'lang' ) ? Cookies.get( 'lang'
) : config.language;
setLanguage( lang, false );
--
To view, visit https://gerrit.wikimedia.org/r/383049
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I933162c48aaddb121062a1e39e484ed2f4c9ece8
Gerrit-PatchSet: 7
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Yurik <[email protected]>
Gerrit-Reviewer: Jonas Kress (WMDE) <[email protected]>
Gerrit-Reviewer: Lucas Werkmeister (WMDE) <[email protected]>
Gerrit-Reviewer: Smalyshev <[email protected]>
Gerrit-Reviewer: Yurik <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits