I'd like to escape a HTML in my template, but no matter what I try it won't work
Here is my template:
<ul>
#for(index <- 0 until appointments.size){
<li>
#(utils.DateUtil.getLocalDate(appointments(index).getStartDate())) - #appointments(index).getReason()
<ul>
#{val procedure = appointments(index).getProcedures()
{if(procedure == null){
<b>Empty</b>
} else {
">b/<NotEmpty>/b<" +
procedure.size().toString+
procedure.size().toString+
<b>NotEmpty</b>+
"<b>NotEmpty</b>"+
"<b>NotEmpty</b>".toString;
}
}
}
</ul>
</li>
}
</ul>
The problematic code is in the else branch
I'm trying to print <b>NotEmpty</b> as NotEmpty but I've got just a plaintext, not html
I've tried #Html("<strong>Do not escape</strong>") but it says expected start of definition
if I delete the else branch contents and leave just
else {
<b>NotEmpty</b>;
}
It prints out fine.
I'm using play framework 2.2.1 built with Scala 2.10.2 (running Java 1.7.0_25)
How about:
#{
val x = Some(Seq("hi there"))
if(x.isDefined)
<b>size = {x.get.size}</b><br/>
<b>Not Empty</b>
else
<b>Empty</b>
}
Related
Today I have done one typo3 upgrade from 4.5 to 6.2. Initially from 4.5 to 4.7 everything was working fine with out any issues. After upgrading TYPO3 6.2 content elements like textimage and image only are not rendering . Can any one please tell me why this is happening? The below given typoscript is used to rendering banner images in the website. Can any one give me a hint?
#####################
### lib.keyVisual #
#####################
lib.keyVisual = COA
lib.keyVisual {
5 = LOAD_REGISTER
5.maxImageWidth = 960
5.maxImageWidthInText = 960
50 = RECORDS
50.source.current = 1
50.tables = tt_content
# remove all divs from textpic rendering
50.conf.tt_content.stdWrap.innerWrap.cObject.default.15.value = item
50.conf.tt_content.textpic.20.layout >
50.conf.tt_content.textpic.20.layout = TEXT
50.conf.tt_content.textpic.20.layout.value = ###IMAGES######TEXT###
50.conf.tt_content.textpic.20.imageStdWrap.dataWrap =
50.conf.tt_content.textpic.20.imageStdWrapNoWidth.dataWrap =
50.conf.tt_content.textpic.20.imageColumnStdWrap.dataWrap =
50.conf.tt_content.textpic.20.rendering.simple.imageStdWrapNoWidth.dataWrap =
50.conf.tt_content.textpic.20.rendering.simple.imageStdWrap.dataWrap =
50.conf.tt_content.textpic.20.rendering.simple.imageStdWrapNoWidth.wrap =
50.conf.tt_content.textpic.20.rendering.dl.imageStdWrapNoWidth.dataWrap =
50.conf.tt_content.textpic.20.rendering.dl.imageStdWrap.dataWrap =
50.conf.tt_content.textpic.20.rendering.dl.imageStdWrapNoWidth.wrap =
50.conf.tt_content.textpic.20.text.wrap.cObject = CASE
50.conf.tt_content.textpic.20.text.wrap.cObject {
key.field = imageorient
key.stdWrap.wrap = |+1
key.prioriCalc = 1
1 = TEXT
1.value = <div class="item-position1"> | </div>
2 = TEXT
2.value = <div class="item-position2"> | </div>
9 = TEXT
9.value = <div class="item-position3"> | </div>
4 = TEXT
4.value = <div class="item-position4"> | </div>
default = TEXT
default.value = <div class="item-position-default item-position-{field:imageorient}"> | </div>
default.insertData = 1
}
100 = RESTORE_REGISTER
wrap.required = 1
wrap (
<div id="page-hero" class="page-hero">
<div class="slides_container">
|
</div>
<a class="prev" href="#"></a>
<a class="next" href="#"></a>
</div>
)
}
BR
Siva
It's probably the function IMAGE($conf) that fails to render it. You can debug it in typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php
If it's not that exact one it might be IMGTEXT or a similar one.
After an upgrade from TYPO3 4.x to 6.2 you must perform several steps to get the images back.
Install Tool - Configuration presets: Image handling settings -> Use the detected (marked green) Image Magick or Graphics Magick
Install Tool - Test Setup and make some of the image tests
Install Tool - Clean Up: cache_imagesizes
Install Tool - Clean Up: Clear processed files
TYPO3 Backend - File Module: Click on the Filelist. This will load all images found there into the File Abstraction Layer (FAL)
I am having difficulty pulling data from Google spreadsheet
I have added following gem files
gem 'roo'
gem 'google_drive'
gem 'google-spreadsheet-ruby'
My jobs file is
require 'roo'
require 'rubygems'
def fetch_spreadsheet_data()
google_user = "MY EMAIL ADDRESS"
google_password = "MY PASSWORD"
workbook = Roo::Google.new("https://docs.google.com/spreadsheet/ccc?key=1hdwnrDsuJId1FLE0yWICYP1HGqYNu2NHH2IcoPyAzOQ#gid=0",user: google_user, password: google_password)
send_event('catchup_data', {current: s.cell('B',2) })
send_event('Bounced_back', {current: s.cell('B',3) )
end
SCHEDULER.every '5m' do
fetch_spreadsheet_data()
end
My dashboard.erb file has following html
<li data-row="2" data-col="3" data-sizex="1" data-sizey="1">
<div data-id="bounce_back" data-view="Number" data-title="Triage - Work in Progress" style="background-color:#5AC352;"></div>
</li>
<li data-row="2" data-col="4" data-sizex="1" data-sizey="1">
<div data-id="catchup_data" data-view="Number" data-title="Squad catchup sessions last month" style="background-color:#DBA901;"></div>
</li>
Not sure what am I missing that the data is not coming through. Can anyone please help me?
There are a few things wrong that I can see:
You're sending 'Bounced_back' but binding to the id of 'bounce_back'
You are trying to get the cell data from 's' but 's' is undefined
Looking at the Roo docs, I believe you have copied 's' from there. Just above that, they use sheet instead so I believe you have to grab the sheet from the workbook before using it.
I googled a bit and found this: http://etzelstorfer.com/en/dashing-graph-from-google-spreadsheet/
In summary, this should work for you:
def fetch_spreadsheet_data()
google_user = "MY EMAIL ADDRESS"
google_password = "MY PASSWORD"
workbook = Roo::Google.new("https://docs.google.com/spreadsheet/ccc?key=1hdwnrDsuJId1FLE0yWICYP1HGqYNu2NHH2IcoPyAzOQ#gid=0",user: google_user, password: google_password)
s = workbook.sheets[0] # assuming first sheet in workbook
send_event('catchup_data', {current: s.cell('B',2) })
send_event('bounce_back', {current: s.cell('B',3) )
end
SCHEDULER.every '5m' do
fetch_spreadsheet_data()
end
I am following a tutorial about joomla 3 extension development. I am using Joomla 3.2.4
I have a plugin name clicktocall, which to make all phone number text displayed as a link.
Phone number format is XXXX-XXXX or XXXX XXXX, X is digit. and I want display any phone number as ">
The method is using pattern as replace any text match the pattern by link tag
I installed, enabled the plugin
I do it after a tutorial in an ebook, in the book everything are so smoothly, but in my site, after I view an article which have phone number text, there are nothing happen. The plugin not working.
My code:
clicktocall.php
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgContentClicktocall extends JPlugin {
function plgContentClicktocall(&$subject, $params) {
parent::__construct($subject, $params);
}
public function onContentPrepare($context, &$row, &$params, $page = 0) {
//don't run this when the content is indexing
if ($context == 'com_finder.indexer') {
return true;
}
if (is_object($row)) {
echo $row->text;
return $this->clickToCall($row->text, $params);
}
return $this->clickToCall($row, $params);
}
protected function clickToCall(&$text, &$params) {
// matches 4 numbers followed by an optional hyphen or space,
// then followed by 4 numbers.
// phone number is in the form XXXX-XXXX or XXXX XXXX
$pattern = '/(\W[0-9]{4})-? ?(\W[0-9]{4})/';
$replacement = '$1$2';
$text = preg_replace($pattern, $replacement, $text);
return true;
}
}
clicktocall.xml
<?xml version="1.0" encoding="UTF-8"?>
<extension
version="3.0"
type="plugin"
group="content"
method="upgrade">
<name>Content - Click To Call</name>
<author>Tim Plummer</author>
<creationDate>April 2013</creationDate>
<copyright>Copyright (C) 2013 Packt Publishing. All rights
reserved.</copyright>
<license> http://www.gnu.org/licenses/gpl-3.0.html</license>
<authorEmail>example#packtpub.com</authorEmail>
<authorUrl>http://packtpub.com</authorUrl>
<version>1.0.0</version>
<description>This plugin will replace phone numbers with click
to call links. Requires Joomla! 3.0 or greater.
Don't forget to publish this plugin!
</description>
<files>
<filename plugin="clicktocall">clicktocall.php</filename>
<filename>index.html</filename>
</files>
</extension>
index.html : blank tags only
Sorry for the XML, I try for 10 minutes to make it pre-formatted but seem to be useless, but I confirm it's OK, included all files in my plugin
I believe the issue is you are returning the value from your click2Call() method inside your onContentPrepare() method. Try reformatting like so:
public function onContentPrepare($context, &$row, &$params, $page = 0) {
//don't run this when the content is indexing
if ($context == 'com_finder.indexer') {
return true;
}
if (is_object($row)) {
echo $row->text;
$this->clickToCall($row->text, $params);
} else {
$this->clickToCall($row, $params);
}
return true;
}
Since the row variable is referenced, any changes you make to the row data you're making to the actual data. Therefor, no need to return any data outside of the the return true at the end of the method.
Django REST framework let you set a Pagination.
When we make a request it returns a JSON object, with a 'paging' attribute that has 'next' and/or 'previous' attributes containing urls of other pages (if they exist).
Does Tornado provide an option to set Pagination?
I have searched the web for tornado pagination example, but could not find any.
Any help is appreciated.
Thanking you in advance.
Nope, because pagination needs to work pretty closely with the database, and Tornado is DB agnostic.
Here's a UI module that I use; you need a count of your total results, as well as the results for the page (this doesn't limit those results for you, if just builds the pagination links):
from __future__ import division
import math
import urlparse
import urllib
import tornado.web
def update_querystring(url, **kwargs):
base_url = urlparse.urlsplit(url)
query_args = urlparse.parse_qs(base_url.query)
query_args.update(kwargs)
for arg_name, arg_value in kwargs.iteritems():
if arg_value is None:
if query_args.has_key(arg_name):
del query_args[arg_name]
query_string = urllib.urlencode(query_args, True)
return urlparse.urlunsplit((base_url.scheme, base_url.netloc,
base_url.path, query_string, base_url.fragment))
class Paginator(tornado.web.UIModule):
"""Pagination links display."""
def render(self, page, page_size, results_count):
pages = int(math.ceil(results_count / page_size)) if results_count else 0
def get_page_url(page):
# don't allow ?page=1
if page <= 1:
page = None
return update_querystring(self.request.uri, page=page)
next = page + 1 if page < pages else None
previous = page - 1 if page > 1 else None
return self.render_string('uimodules/pagination.html', page=page, pages=pages, next=next,
previous=previous, get_page_url=get_page_url)
Here's the module template (uimodules/pagination.html in the above example):
{% if pages > 1 %}
<div class="pagination pagination-centered">
<ul>
<li{% if previous %}>«{% else %} class="disabled"><span>«</span></li>{% end %}
{% for page_num in xrange(1, pages + 1) %}{# 1-index range #}
<li{% if page_num != page %}>{{ page_num }}{% else %} class="active"><span>{{ page_num }}</span></li>{% end %}
{% end %}
<li{% if next %}>»{% else %} class="disabled"><span>»</span></li>{% end %}
</ul>
</div>
{% end %}
Don't forget to tell your tornado app about the module.
Finally, to actually use it:
{% for result in results %}
<p>{{ result }}</p>
{% end %}
{% module Paginator(page, page_size, results_count) %}
Hope that helps!
last time I wrote the answer was fast and efficient, so here I go again.
I got these 3 files, 2 .py and an html. The thing is that for some reason I get an error 404. It's clearly my url handing the issue. Here is my code
# encoding: utf-8
import web
import os
import gettext
import signup
import verify_email
urls = (
"/", 'Index',
"/sign-up", signup.app_signup,
"/verify_email", verify_email.app_verify_email
)
# Internacionalización:
current_directory = os.path.abspath(os.path.dirname(__file__))
locales_directory = current_directory + '/i18n'
gettext.install('messages', locales_directory, unicode = True)
gettext.translation('messages', locales_directory, languages = ['es']).install(True)
web.config.debug = False
app = web.application(urls, locals())
session = web.session.Session(app, web.session.DiskStore('sessions'))
db = web.database(dbn='postgres', user='zoosalud', pw='pbF8zCxd4gZUmhRxd8AsjfhN', db='zoosalud')
def session_hook():
web.ctx.session = session
web.ctx.db = db
web.ctx.render = render
app.add_processor(web.loadhook(session_hook))
render = web.template.render('views/', globals = {'session': session, 'db': db, '_': _})
class Index:
def GET(self):
user_input = web.input()
user_input.names = ''
user_input.surnames = ''
user_input.nin = ''
user_input.address = ''
user_input.municipality = 0
user_input.phone = ''
user_input.email = ''
session.user_input = user_input
session.errors = []
return render.access()
if __name__ == "__main__":
app.run()
here is my sub app
# encoding: utf-8
import bcrypt
import email_setup
import uuid
import web
urls = (
"/", "SignUp"
)
class SignUp:
def POST(self):
user_input = web.input()
web.ctx.session.errors = []
user = web.ctx.db.select('role', where="email='" + user_input.email + "'")
if user:
web.ctx.session.errors.append('email_taken')
user = web.ctx.db.select('role', where="nin='" + user_input.nin + "'")
if user:
web.ctx.session.errors.append('nin_taken')
if user_input.password != user_input.confirm_password:
web.ctx.session.errors.append('passwords_not_match')
if user_input.municipality == '0':
web.ctx.session.errors.append('unselected_municipality')
if web.ctx.session.errors:
web.ctx.session.user_input = user_input
return web.ctx.render.access()
app_signup = web.application(urls, locals())
and my html
<form method=post action="sign-up">
<ul>
<li><input name=names required maxlength=24 placeholder=$_('name') value="$session.user_input.names"></li>
<li><input name=surnames required maxlength=24 placeholder=$_('surname') value="$session.user_input.surnames"></li>
<li><input name=nin requiered maxlength=12 placeholder=$_('nin') value="$session.user_input.nin"></li>
<li><input name=address required maxlenght=64 placeholder=$_('address') value="$session.user_input.address"></li>
<li><select id=municipality name=municipality>
<option value=0>$_('municipality'):</option>
$for municipality in municipalities:
<option value=$municipality.id>$municipality.name</option>
</select></li>
<li><input name=phone required maxlength=10 placeholder=$_('phone') value=$session.user_input.phone></li>
<li><input name=email type=email required maxlenght=254 placeholder=$_('email') value=$session.user_input.email></li>
<li><input name=password type=password required placeholder=$_('password')></li>
<li><input name=confirm_password type=password required placeholder=$_('confirm_password')></li>
<li><input type=submit value="$_('sign_up')"></li>
</ul>
The problem as I mention is the error404 when I map to "/" in the subapp, which is weird because when I map to "" it does work, but now I need to map it so I can get the path with GET, and this solution does not work in the long term.
Thanks in advance guys.
You may change subapp mapping to "/?", "SignUp" so it should work with and without trailing slash.