Not able to pass base url for different test build environment in ember cli - ember-cli

I am trying to set different base url for development test and stage test environments in ember cli.
Test environment name is always same (which is "test") irrespective of environment passed in command line.
Am looking for some thing like this. Please let me know if anyone have any solution.Thanks in advance
if (environment === 'development') {
ENV.baseURL = '/';
}
if (environment === 'test') {
if (ENV PASSED === 'stage')
ENV.baseURL = '/stage';
else
ENV.baseURL = '/';
}
if (environment === 'stage') {
ENV.baseURL = '/stage';
}

In your config/environment.js, do something like this:
if (environment === 'development') {
ENV.baseURL = '/';
}
if (environment === 'test') {
ENV.baseURL = '/';
}
if (environment === 'stage') {
ENV.baseURL = '/stage';
}
if (environment === 'production') {
ENV.baseURL = '/';
}
Then to use the ENV on stage environment, invoke the ember-cli like so:
ember server --environment=stage

Related

cannot print a defined environment variable inside powershell step in jenkinsfile

I am having trouble accessing the environment variable that I defined in Jenkinsfile ( Groovy ).
My situation is that I can access the variable in any step outside the powershell ''' ''' but when I try to access it inside the powershell then it gives null value.
pipeline {
environment {
APP_BUILD = ''
BUILD_NUM = ''
APP_NAME = ''
}
agent {
label 'test'
}
stages {
stage('set env Variables ') {
steps{
script {
APP_BUILD = "name"
echo APP_BUILD
//prints name which is expected and fine
powershell '''
echo $env:APP_BUILD // does ot print anything
echo $env:BUILDNUMBER // prints the build number
'''
}
}
}
}
}
I tried to search for an solution where they say that if I use powershell """ """ , it might work but then I cannot assign it to other variable as in code below
pipeline {
environment {
APP_BUILD = ''
BUILD_NUM = ''
APP_NAME = ''
}
agent {
label 'test'
}
stages {
stage('set env Variables ') {
steps{
script {
APP_BUILD = "name"
echo APP_BUILD
//prints name which is expected and fine
powershell """
echo ${env:APP_BUILD} // prints output as expected
echo $env:BUILDNUMBER // prints the build number
$build=${env:APP_BUILD} // gives an error saying groovy.lang.MissingPropertyException: No such property: build for class: groovy.lang.Binding
"""
}
}
}
}
}
then it echo the output but everytime I try to assign the environment variable to another local variable then it gives error which says
groovy.lang.MissingPropertyException: No such property: build for class: groovy.lang.Binding
Please let me know if anyone has faced similar situations and solved it.
You have to escape the '$' character when referring to PS variables, otherwise Groovy will try to interpolate:
powershell """
echo "$APP_BUILD" # it's simpler to let Groovy interpolate
echo "$BUILDNUMBER" # it's simpler to let Groovy interpolate
\$build="$APP_BUILD" # need to escape '$' when referring to PS variable
"""

How to see map when i launch nominatim?

When I open http://[IP]/nominatim/ I get only code
I've installed via tips from that link https://nominatim.org/release-docs/latest/admin/Installation/ and also made data import.
And all I see when I open this link is that code.
getPreferredLanguages(); $oGeocode->setLanguagePreference($aLangPrefOrder); if (CONST_Search_ReversePlanForAll || isset($aLangPrefOrder['name:de']) || isset($aLangPrefOrder['name:ru']) || isset($aLangPrefOrder['name:ja']) || isset($aLangPrefOrder['name:pl']) ) { $oGeocode->setReverseInPlan(true); } // Format for output $sOutputFormat = $oParams->getSet('format', array('html', 'xml', 'json', 'jsonv2', 'geojson', 'geocodejson'), 'html'); $sForcedGeometry = ($sOutputFormat == 'html') ? 'geojson' : null; $oGeocode->loadParamArray($oParams, $sForcedGeometry); if (CONST_Search_BatchMode && isset($_GET['batch'])) { $aBatch = json_decode($_GET['batch'], true); $aBatchResults = array(); foreach ($aBatch as $aBatchParams) { $oBatchGeocode = clone $oGeocode; $oBatchParams = new Nominatim\ParameterParser($aBatchParams); $oBatchGeocode->loadParamArray($oBatchParams); $oBatchGeocode->setQueryFromParams($oBatchParams); $aSearchResults = $oBatchGeocode->lookup(); $aBatchResults[] = $aSearchResults; } include(CONST_BasePath.'/lib/template/search-batch-json.php'); exit; } $oGeocode->setQueryFromParams($oParams); if (!$oGeocode->getQueryString() && isset($_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'][0] == '/' ) { $sQuery = substr(rawurldecode($_SERVER['PATH_INFO']), 1); // reverse order of '/' separated string $aPhrases = explode('/', $sQuery); $aPhrases = array_reverse($aPhrases); $sQuery = join(', ', $aPhrases); $oGeocode->setQuery($sQuery); } $hLog = logStart($oDB, 'search', $oGeocode->getQueryString(), $aLangPrefOrder); $aSearchResults = $oGeocode->lookup(); if ($sOutputFormat=='html') { $sDataDate = chksql($oDB->getOne("select TO_CHAR(lastimportdate,'YYYY/MM/DD HH24:MI')||' GMT' from import_status limit 1")); } logEnd($oDB, $hLog, count($aSearchResults)); $sQuery = $oGeocode->getQueryString(); $aMoreParams = $oGeocode->getMoreUrlParams(); if ($sOutputFormat != 'html') $aMoreParams['format'] = $sOutputFormat; if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $aMoreParams['accept-language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE']; } $sMoreURL = CONST_Website_BaseURL.'search.php?'.http_build_query($aMoreParams); if (CONST_Debug) exit; $sOutputTemplate = ($sOutputFormat == 'jsonv2') ? 'json' : $sOutputFormat; include(CONST_BasePath.'/lib/template/search-'.$sOutputTemplate.'.php');
Local.php in build directory
<?php
#define('CONST_Database_Web_User', 'apache');
#define('CONST_Website_BaseURL', 'http://geocoder.cloudapp.net/');
#define('CONST_Postgresql_Version', '9.5');
#define('CONST_Postgis_Version', '2.2.1');
Also i've had added it in apache conf
<Directory "/srv/nominatim/Nominatim-3.2.0/website">
Options FollowSymLinks MultiViews
AddType text/html .php
DirectoryIndex search.php
Require all granted
</Directory>
Alias /nominatim /srv/nominatim/Nominatim-3.2.0/website
I expect to see map, not code.

get pagename in my wordpress plugin

I am adding specific js file to the front end from my wordpress plugin.
For Example :
if($wp->query_vars["pagename"] == 'pagename1'){
include js file 1.
}else if($wp->query_vars["pagename"] == 'pagename1'){
include js file 2.
}
But now i am not able to get the page name in$wp->query_vars.
Thank you
Balaji
Try this:
$post = get_post();
$post_name = $post->post_name;
To add javascript you could do this:
add_action( 'wp_enqueue_scripts', 'addSomescripts' );
function addSomeScripts() {
$post = get_post( );
$post_name = $post->post_name;
if($post_name == 'pagename1') {
wp_enqueue_script('script1', '/pathtoscript1.js');
} else if($post_name == 'pagename2') {
wp_enqueue_script('script2', '/pathtoscript2.js');
}
}

Jasmine unit test using injection

In this test I am unsure why you need to set the angular variable to the injection params in these 2 lines. Is it because the injection doesn't automatically assign the $compile and $rootScope?
$compile = $c;
$rootScope = $r;
from
describe("Unit: Testing Directives", function() {
var $compile, $rootScope;
beforeEach(module('App'));
beforeEach(inject(
['$compile','$rootScope', function($c, $r) {
$compile = $c;
$rootScope = $r;
}]
));
it("should display the welcome text properly", function() {
var element = $compile('<div data-app-welcome>User</div>')($rootScope);
expect(element.html()).to.match(/Welcome/i);
})
});
Try something like this it works for me:
beforeEach(inject(function ($injector) {
$rootScope = $injector.get('$rootScope');
$scope = $rootScope.$new();
$http = $injector.get('$http');
$q = $injector.get('$q');
}));

How is defined current url in zend (inside job of a framework)

Tell please what script uses zend framework for definition current URL? More exactly I interest what use ZEND for definition domain name: this $_SERVER['HTTP_HOST'] or this
$_SERVER['SERVER_NAME'] ? (or may be something other)?
P.S. ( I search in documentation but not found, (I do not know this framework), also I search in google, but also not found answer on my question? )
Try use: $this->getRequest()->getRequestUri() to get current of requested URI.
In the view script use: $this->url() to get current URL.
Or using via static integrated Zend Controller front via instance:
$uri = Zend_Controller_Front::getInstance()->getRequest()->getRequestUri();
You can get a value of URI implementation via singleton to get a value of request() data:
$request = Zend_Controller_Front::getInstance()->getRequest();
$url = $request->getScheme() . '://' . $request->getHttpHost();
On the View use it as:
echo $this->serverUrl(true); # return with controller, action,...
You should avoid hardcode such as example (NOT TO USE!):
echo 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
instead of this example use as on a view:
$uri = $this->getRequest()->getHttpHost() . $this->view->url();
If you want using getRequest in ZEND more explore The Request Object.
SKIP IT BELOW (AUTOPSY EXAMPLE HOW WORKS IT).
Full of example code how getRequestUri() how it works and why is isRequest instead using $_SERVER is because on a platform specific is randomly get a data:
first if uri null, thand if requested from IIS set is as HTTP_X_REWRITE_URL. If not, check on IIS7 rewritten uri (include encoded uri). If not on IIS than REQUEST_URI will check scheme of HTTP_HOSTNAME, or if failed use as ORIG_PATH_INFO and grab a QUERY_STRING.
If is setted, grab a data automatically via string of returned object $this in a class.
If failed, than will be set a parsed string than set it.
if ($requestUri === null) {
if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
$requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
} elseif (
// IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)
isset($_SERVER['IIS_WasUrlRewritten'])
&& $_SERVER['IIS_WasUrlRewritten'] == '1'
&& isset($_SERVER['UNENCODED_URL'])
&& $_SERVER['UNENCODED_URL'] != ''
) {
$requestUri = $_SERVER['UNENCODED_URL'];
} elseif (isset($_SERVER['REQUEST_URI'])) {
$requestUri = $_SERVER['REQUEST_URI'];
// Http proxy reqs setup request uri with scheme and host [and port] + the url path, only use url path
$schemeAndHttpHost = $this->getScheme() . '://' . $this->getHttpHost();
if (strpos($requestUri, $schemeAndHttpHost) === 0) {
$requestUri = substr($requestUri, strlen($schemeAndHttpHost));
}
} elseif (isset($_SERVER['ORIG_PATH_INFO'])) { // IIS 5.0, PHP as CGI
$requestUri = $_SERVER['ORIG_PATH_INFO'];
if (!empty($_SERVER['QUERY_STRING'])) {
$requestUri .= '?' . $_SERVER['QUERY_STRING'];
}
} else {
return $this;
}
} elseif (!is_string($requestUri)) {
return $this;
} else {
// Set GET items, if available
if (false !== ($pos = strpos($requestUri, '?'))) {
// Get key => value pairs and set $_GET
$query = substr($requestUri, $pos + 1);
parse_str($query, $vars);
$this->setQuery($vars);
}
}
$this->_requestUri = $requestUri;
return $this;