Twitter bootstrap – modal not working in firefox

Quick heads up for those having issues getting the modal window in the twitter bootstrap to work in firefox, I had a problem where the overlay would show but not the actual modal window content. Seems there is a problem if you’re using animation (fade etc).

See here for more information.

For now we use no animation, so a typical modal source example might be (note: no animation as is the default in the docs):

<div id="preview-modal" class="modal hide">
	<div class="modal-header">
		<a href="#" class="close">&times;</a>
		<h3>Modal Heading</h3>
	</div>
	<div class="modal-body">
		<p>One fine body…</p>
	</div>
	<div class="modal-footer">
		<a href="#" class="btn primary">Primary</a>
		<a href="#" class="btn secondary">Secondary</a>
	</div>
</div>

Typically there is “fade” in the class of the parent div which we’ve removed.

3 Comments |Tags:

Customising search results from google cse

Google custom search engine (cse) is pretty cool, in fact it’s very cool. Within minutes you can have the ability to search your entire site all with a snippet of code! And for a nominal fee you can deliver these results without ads :)

We use google cse for most of our sites but the other day we ran into a slight problem. The site in question has both public and private access, the public site is delivered over http and has plenty of indexable content. This is what we use google cse for. The issue came about once a user was logged in, their session is maintained via secure cookies over https. But the problem was that if they performed a search, all the results that cse returned directed users to http which effectively logged them out of the site (i.e. the user was no longer on https, as we don’t send cookies over http no session existed).

Even changing the site to index as https inside the cse control panel didn’t fix the issue, so we started to look for solutions to customise the results. Here are a few immediate options:

  • Use the JSON API
  • Return the results as XML
  • Use custom templates

The JSON API is super cool but from what I can see there’s a crazy limit of 150 queries per day unless you pay $5 per 1000 queries. Wow, no thanks.

XML is of course a tried and true approach but kinda clunky and verbose.

That leaves custom templates, from google:

The specification that allows you to customize results is a minimal form of the template languages used by OpenSocial and jstemplates.

This is a super cool and super easy way to modify the rendering of your custom google search results. Of course if you need to make big changes to the results then one of the other options is probably your best bet, but for what we wanted to achieve (delivering cse results as https) this was fine.

How does it work? Add your JavaScript snippet as usual:

<script type="text/javascript">
	google.load('search', '1', {language : 'en', "nocss": true});
	google.setOnLoadCallback(function() {
		var customSearchControl = new google.search.CustomSearchControl('003499422247080460488:qvs6fhb5k8o');
		customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
		var options = new google.search.DrawOptions();
		options.setAutoComplete(true);
		google.search.Csedr.addOverride("bos_");
		customSearchControl.draw('cse', options);
	}, true);
</script>

We override the css from google and turn on autocomplete, apart from that the most important thing to note is the addOverride() option. Essentially here you add a prefix specific to your site, in this case ours is “bos_”. Google will look for this prefix, along with several specific values to render the content.

For example the main results appear in a section called webResult, so create a div with an id of your prefix + “webResult”

<div id="bos_webResult">

This is where google will look render the search results. A full example:

<div id="bos_webResult">
	<div class="gs-webResult gs-result"
	data-vars="{longUrl:function() {
	  var i = unescapedUrl.indexOf(visibleUrl);
	  return i < 1 ? visibleUrl : unescapedUrl.substring(i);}}">
		<table>
			<tr>
				<td valign="top">
					<div class="gs-title">
						<a class="gs-title" data-attr="{href:unescapedUrl.replace('http://', 'https://'),target:target}" data-body="html(title.replace('Our site tite :: ', ''))"></a>
					</div>
					<div class="gs-snippet" data-body="html(content)"></div>
					<div class="gs-visibleUrl gs-visibleUrl-long" data-body="longUrl()"></div>
				</td>
			</tr>
		</table>
	</div>
</div>

You can see that we’re using the template language “data-xxx” attributes on the “a” tag to modify the results returned from cse. In the example above we use the data-attr to replace “http://” with “https://” and also the data-body to replace the site title. This is possible because the templating approache evaluates JavaScript, nice!

There are many more options available with this approach, great to see google provide so many ways to render their search results.

This templating approach is another fantastic way to simplify the modifying the results from google cse. Read more on their docs.

1 Comment

FarCry Plugin – Webtop Tools

We’re starting to compile a list of internal tools used when developing a FarCry application. I thought it might be simpler to create a small FarCry plugin to keep them all in the same place, makes it easier to use across multiple projects.

The plugin currently contains 2 scripts:

  • FarCry database diff (MySQL only at this stage)
  • Content Object Meta

The database diff looks for case-sensitivity differences between your ColdFusion components and the actual MySQL table names (MySQL only). Historically we’ve had issues because we are on Linux, this tool has helped quickly iron out any differences in “case”.

The Content Object Meta assists in finding information about content of any “type” in FarCry, based on the title, objectId or friendly URL. What does this mean? Well any “content object” you want information on can be found using this tool. Whether you have an objectId and you don’t know if it belongs to dmNavigation, dmHTML, dmNews or a custom type. Or you might have part of a friendly URL or content label/title. This tool can help tell you what the content type is, whether it’s approved, where it sits in the site tree (if relevant) etc.

For example; if I wanted to know everything in FarCry that had a label LIKE ‘credential’ (wildcards are automatically added to your search term) I might get results like the following:

From that initial resultset, if I clicked on an objectid for dmNavigation:

Or if I clicked on an objectid for dmHTML:

Note that there is a collapsed cfdump that you can expand for further info.

Requirements
——————————-

Railo 3.2+ or ColdFusion 7+
FarCry 6+
MySQL 5+

Installation
——————————-

“Official” notes on installing FarCry plugins can be found here: https://farcry.jira.com/wiki/pages/viewpage.action?pageId=12943398

It’s pretty simple though:

  • add the “lcwebtoptools” directory from git into /farcry/plugins/
  • add “lcwebtoptools” to THIS.plugins in farcryConstructor.cfm (in your project webroot)

e.g. <cfset THIS.plugins = “farcrycms,lcwebtoptools”>

Restart your app, that’s it. No coapi changes need to be made. To access the current tools, go to the “Admin” tab and choose “Webtop Tools” from the drop down.

The plugin is hosted on github, for a direct download to the zip click here.

1 Comment

Label vs Title in FarCry

All system content objects (and those custom types which extend “types” or “versions” etc) in FarCry have the “label” and “title” properties. Most of the time the value of these are identical, I find myself typically using the “title” property in formtools as well as any display methods. The question of course is why have both these if they’re always exactly the same?

A note on the FarCry forums suggested that this was a handy way split what you might want to use in a display method vs an admin screen or any other scenario etc. Well today I had need to do exactly this, and combined with some of the custom metadata for your type components I’ve found that this is yet another simple but powerful feature of FarCry core.

Scenario

I have a custom type, a “topic”. Now these topics have titles but also “codes” associated with them. Sometimes I’ll want to output just the title, but sometimes I’ll want to output the code + title together. Sure stObj gives me the simple ability to access these singularly, but having the ability to store this composite value in the label field (as well as the single title in the “title” field) gives me freedom to display this in places like the object admin screen, generic nav, breadcrumbs etc. Very very nice.

How

Ok first you need to enable auto labels for your type:

<cfcomponent extends=”farcry.core.packages.types.versions” displayname=”ACE Topic” bUseInTree=”0″ bFriendly=”1″ fuAlias=”acetopic” bObjectBroker=”0″ bAutoSetLabel=”true”>

Then for each property you’d like combined for your label, set a bLabel attribute to true.

<cfproperty name=”Code” type=”string” required=”no” default=”" ftSeq=”1″ ftwizardStep=”Content” ftValidation=”required” ftFieldset=”General Details” bLabel=”true”>

<cfproperty name=”Title” type=”string” hint=”Title of content item.” required=”no” default=”" ftSeq=”2″ ftwizardStep=”Content” ftFieldset=”General Details” ftValidation=”required”  bLabel=”true”>

What this now does (after you edit a content object) is save the “code + title” in the label field. Cool :)

No Comments

FarCry Tip – Enable cfc’s in your Railo ProxyPassMatch

I ran into an issue today while working on a FarCry project, basically when I opened up the “Related Content” popup from the WYSIWYG editor it was blank. Nothing. Not the usual tabs for Images, File, Flash etc.

The Railo logs were empty but Apache was throwing a strange error which I hadn’t seen before: “Couldn’t initialize from remote server, JRun server(s) probably down.”. Funny as I’m not even using JRun!

Looking at the Chrome console I could see that opening the popup made a request directly to a cfc (/webtop/facade/tinyMCE.cfc?method=ajaxGetTemplateDropdowns) and returned the following error: “Failed to load resource: the server responded with a status of 500 (Internal Server Error)

Eventually Mark pointed me in the right direction which was kind of obvious if I’d actually read the error properly! Our config for Apache -> Railo is for cfm’s only…not cfc’s. I don’t really like the approach of calling cfc’s directly at all, which is why it’s not in our Apache -> Railo proxy. But it wasn’t a big deal to add it for FarCry projects.

Here is the config we now use, note we now pass requests for cfm and cfc to Railo:

        <IfModule mod_proxy_ajp.c>
                <Proxy *>
                        Order deny,allow
                        Allow from all
                </Proxy>
                ProxyPassMatch ^/(.*\.cf[cm])$ ajp://127.0.0.1:8009/$1
                ProxyPassReverse  /  ajp://127.0.0.1:8009/
        </IfModule>

And of course now the related content popup works :)

No Comments