HTML Codes in CakePHP $html->link function - html

This code
$html->link(" »", '/events/view/'.$event['Event']['id']), array('escape'=>false,'class'=>'more') )
Outputs
»
instead of >>
Any idea?

basically you have syntax error instead you should have:
$this->Html->link(" »", '/events/view/'.$event['Event']['id'], array('escape'=>false,'class'=>'more') );
At least that's what I see.

Related

Customize protractor-html-screenshot-reporter

I'm generating an HTML report using protractor-html-screenshot-reporter.
I get false/true under the Passed column but I want Passed/Failed instead.
Expected - Failed(in red) or Passed(in green)
Actual - False(in red) or True(in green)
Code Snippet -
function defaultMetaDataBuilder(spec, descriptions, results, capabilities) {
var metaData = {
description: descriptions.join(' ')
, passed: results.passed()
, os: capabilities.caps_.platform
, browser: {
name: capabilities.caps_.browserName
, version: capabilities.caps_.version
}
, message: ''
}
If I replace passed: results.passed() by this code -
passed: results.passed() ? 'Passed' : 'Failed'.
I get Passed/Failed instead of True/False but Failed also comes in Green.
How should I handle this scenario. Any suggestions are always welcome
You have to alter how the page is rendered. Looking at source code for protractor-html-screenshot-reporter I can see that the page is fully created in javascript file.
Go to this library source code to jsonparser.js(protractor-html-screenshot-reporter/lib/jsonparser.js) and modify function generateHTML(data). Currently it looks at data.passed to see if this boolean is true or false. Based on that it generates color and prints this value to the column. You want to edit this line to something like this:
str += '<td class="status-col" style="color:#fff;background-color: '+ bgColor+'">' + (data.passed ? "Passed" : "Failed") + '</td>';
Personally if you expect to modify this page even more, I would advice you to move this code into html page instead of generating it inside javascript file.

unable to insert html code inside filter?

Angualr JS code:
$scope.rupee = $filter('currency')($scope.dols * 67.33, 'INR', 3);
I am trying to insert html code inside this filter. That is instead of 'INR', I wish to get ₹ symbol. Please help me to solve this. And the problem is not getting the ₹ through filter. Instead of 'INR', I want to use &#8377 but it's not rendering as I expected.
html code:
<div>{{rupee}}</div>
Modify your statement to
$scope.rupee = $filter('currency')($scope.dols * 67.33, '\u20B9', 3);
As you asked, "Can we write HTML code inside symbolFormat parameter?"
Answer will be below:
It takes a string parameter, so whatever string you are providing, it will be used to apply as currency symbol
For reference you can check Here
You can try like this:
{{ currency_expression | currency : symbol : fractionSize}}
$scope.rupee = $filter('currency')($scope.dols * 67.33, '₹', 3);
See all use cases (currency symbol & sign - in controller & directly on view):
<div ng-app ng-controller="RupeeCtrl">
<b>From controller with sign</b><br/>
{{rupeeSign}}
<br/><br/>
<b>From controller with code</b><br/>
{{rupeeCode}}
<br/><br/>
<b>From view</b><br/>
{{ price | currency:'₹'}}
</div>
function RupeeCtrl($scope, $filter) {
$scope.price = 75.255;
$scope.rupeeSign = $filter('currency')($scope.price, '₹', 3);
$scope.rupeeCode = $filter('currency')($scope.price, '\u20B9', 3);
}
JSFiddle
Mixed with answer from #Romesh Jain
This looks like a duplicate question to this: How to get specific currency symbol(rupee symbol in my case) in angular js instead of the default one (dollar $ symbol)
Just use this ASCII code for the Rupee symbol: ₹
See the ASCII code here: http://www.fileformat.info/info/unicode/char/20b9/index.htm

Strip specific part of query result in python

I have wrote that script that uses yandex api to convert some foreign characters in english, here is the code:
for pre in soup.select('body'):
pree= pre.text
print (pree)
HTML is:
<body>
onComplete_10([{"Alignment":"0:1-0:4 2:2-6:9 3:3-6:9","From":"zh-CHS","OriginalTextSentenceLengths":[4],"TranslatedText":"Drama Arts","TranslatedTextSentenceLengths":[10]}]);
</body>
Returned result is(of course):
onComplete_10([{"Alignment":"0:1-0:4 2:2-6:9 3:3-6:9","From":"zh-CHS","OriginalTextSentenceLengths":[4],"TranslatedText":"Drama Arts","TranslatedTextSentenceLengths":[10]}]);
I need to get only translated text which is "Drama Arts".
NOTE:
I have updated my for loop. Now using regex to filter my required data but still no luck.
for pre in soup.select('body'):
p = re.compile(ur'"TranslatedText":"(.*?)"')
strr = pre.text
pree = re.findall(p, strr)
print (pree)
Just changed it a bit was doing a slight mistake. Though for some reason above works with regex101.
for pre in soup.select('body'):
p = re.compile(u'"TranslatedText":"(.*?)"')
strr = pre.text
pree = re.findall(p, strr)
print (pree)

MediaWiki: changing the label of a category at the bottom of the page

In mediawiki, is it possible to change the label of a 'Category' at the bottom of an article.
For example for the following article:
=Paris=
blablablablablabla
[[Category:place_id]]
I'd like to see something more verbose like (the example below doesn't work):
=Paris=
blablablablablabla
[[Category:place_id|France]]
Note: I don't want to use a 'redirect' and I want to keep my strange ids because they are linked to an external database.
I do not think mediawiki is supporting this feature.
However, how about using:
[[Category:France]]
in your page, and set it into the category named with your id? France would just be a subcategory of "place_id", and you could use more terms all linked to the parent category. For this, you just need to edit the category page for "France", inserting:
[[Category:place_id]]
An alternative would be to put your page in both categories, but in this case, the id would still be displayed:
[[Category:place_id]]
[[Category:France]]
You could do this with an OutputPageMakeCategoryLinks hook. Alas, the interface for that hook seems to be a bit inconvenient — as far as I can tell, it's pretty much only good for replacing the standard category link generation code entirely. Still, you could do that is you want:
function myOutputPageMakeCategoryLinks( &$out, $categories, &$links ) {
foreach ( $categories as $category => $type ) {
$title = Title::makeTitleSafe( NS_CATEGORY, $category );
$text = $title->getText();
if ( $text == 'Place id' ) {
// set $text to something else
}
$links[$type][] = Linker::link( $title, htmlspecialchars( $text ) );
}
return false; // skip default link generation
}
$wgHooks['OutputPageMakeCategoryLinks'][] = 'myOutputPageMakeCategoryLinks';
(The code above is based on the default category link generation code in OutputPage.php, somewhat simplified; I assume you're not using language variant conversion on your wiki, so I removed the parts that deal with that. Note that this code is untested! Use at your own risk.)

preg_replace not working

I have this function in my website.
function autolink($content) {
$pattern = "/>>[0-9]/i" ;
$replacement = ">>$0";
return preg_replace($pattern, $replacement, $content, -1);
This is for making certain characters into a clickable hyperlink.
For example, (on a thread) when a user inputs '>>4' to denote to the another reply number 4, the function can be useful.
But it's not working. the characters are not converted into a hyperlink. They just remain as plain text. Not clickable.
Could someone tell me what is wrong with the function?
So the objective is to convert:
This is a reference to the >>4 reply
...into:
This is a reference to the >>4 reply
...where ">" is the HTML UTF-8 equivalent of ">". (remember, you don't want to create HTML issues)
The problems: (1) you forgot to escape the quotes in the replacement (2) since you want to isolate the number, you need to use parentheses to create a sub-pattern for later reference.
Once you do this, you arrive at:
function autolink($contents) {
return preg_replace( "/>>([0-9])/i",
">>$1",
$contents,
-1
);
}
Good luck