In custom adaptor, where is the file's title property I have to set? - google-search-appliance

I'm making custom file adaptor using adaptor library.
In my adaptor getDocContent(), I retrieve file from URL, and set the content to the Response's OutputStream like sharepoint connector do.
So, I thought "Where is the file's title property I have to set? This is just a content."
As I was thinking, the file does not hit by it's title on the GSA search API. Also by File Extension Filter.

When developing a connector for Google Search Appliance using the Adaptor Framework, you have a few options on how to display metadata. You can send metadata via HTTP headers, but this lacks somehow. For example, when your metadata is too long, it will get truncated (because of it's size).
Since some time we use Handlebars for templating in GSA connectors. You pass your retrieved object to Handlebars, after which you can compose an HTML document such as following:
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="{{object.description}}"/>
<meta name="filetype" content="{{object.filetype}}"/>
<title>{{object.title}}</title>
</head>
<body>
<h1>{{object.title}}</title>
<p>{{object.description}}</p>
<p>{{object.someMoreContent}}</p>
</body>
</html>
So when you getDocContent method is invoked (usually, when GSA crawls you connector), it will crawl the page you design with HTML and HandleBars. Very straightforward and easy to maintain!

Related

No head section when requesting page via YQL API

I'm trying to get the full page via yahoo YQL API, in order to access metadata fields defined in the target page head section (specifically open graph metadata).
My example URL:
http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22http://www.google.com%22&format=xml
But it does not contain any metadata parameters...is there another way to call this Yahoo API to include the head section or perhaps a similar service that does include the head section?
You cannot use YQL to parse google.com directly, use the Community
Tables
Here's an example to get the meta tags of http://php.net/explode via YQL.
SELECT * FROM html WHERE url = 'http://php.net/explode' AND xpath='descendant-or-self::meta'
Partial Query Output:
<results>
<meta charset="utf-8"/>
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
</results>

add text only version to an email template

We use mandrill to send emails and we have many templates defined to send emails. Below is one such template
<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
----- some styling information ----
</style>
</head>
<body>
------ Other html content ------
</body>
</html>
As you can see there is no mention of text only version of this email template. To improve the chances of this email not going to spam i also want to add text only version of it as well. I got to know about "multipurpose internet mail extensions" but i still do not understand how i can make my email to have a text only version too.
I will be really grateful for any kind of help on this.
Strongly suggest using a templating service on top of Mandrill, such as apostle or sendwithus.
Makes it way easier to manage and edit html+text templates, and I believe both support your use case.
You didn't indicate anything about your environment, where you're storing the templates, or whether you're using Mandrill's SMTP integration or API. Those things can make a difference in how/where you store the text versions of your templates.
If you're generating the full SMTP message in some fashion in your system, then you'd need to create a multi-part/alternative MIME document to store the text version. Or use a library or templating engine that can generate this for you in accordance with the relevant specifications.
If you're storing them in your system, and using the Mandrill API, then you'd want to store a separate text version to pass in the text parameter.
For Mandrill templates, there's an explicit text version that can be provided and saved.
Alternately, Mandrill has an option to auto-convert your HTML to text. It can be configured in your Sending Defaults, or on a per-message basis through the API or with SMTP headers.

How can I create a variable Meta property og:image for multiple pages?

Here's the code i'm trying to get work which should explain what I'm trying to do.
<script>document.write('<meta property="og:image" content="' + location.pathname.replace(/\.html$/, '.jpg') + '">')</script>
Just trying to edit meta property create an image for the og:image that has the same name of the .html file. So far no luck
Facebook thumbnail images are generated through something like a search engine web-crawler. It follows links and fetches the needed data from the page. But clients like web crawlers and fb-share only see your HTML, not all the resources on a page - namely client-side scripts like javascript & jQuery. That means your script will not be run, and thus the meta tag not created. Instead try a PHP server side implementation like:
http://mylink.com/?ogimage_id=7 calls
<meta property="og:image" content= <?php $path_to_image_dir . "/" $_GET['ogimage_id']
See my answer here Facebook sharer.php, how to have multiple og:image tags?

Facebook button for Ajax Pages, how to implement and verify that it works

I wanted to know how can I use Facebook Like button on my Ajax web application, that will capture changes in the Open Graph tags for both the og:title and the og:url. I already created a Facebook app and got an API ID.
What I want to know is the code that I need to put on my website in order for Facebook to capture the changes that I've made to the meta tags which contains that title and url information (ie. og:title, og:url).
I followed the instructions on Facebook without success. Furthermore, I want to know how can I locally test the Like button to see that it grabs the data from the Open Graph tags properly.
Also worth mentioning that I've a JQuery code that automatically alters the Open Graph meta tags to include the relevant information for the current Ajax changed page.
Thanks.
You will need to have a separate url for each different page that you want to allow people to like. I would recommend actually pointing the like button to the physical pages you're trying to return via the og:url tag. To refresh the data that Facebook stores about a given url, pass that url into the linter at http://developers.facebook.com/tools/lint.
i created a rotator file for facebook share on my dynamic ajax website.
rotator.asp code sample:
<html>
<% lang=request("lang")
id=request("id")
..some sql to get data...
ogTitle=....
ogImage=....
originalUrl=....
%>
<head>
<meta property="og:title" content="<%=ogTitle%>" />
<meta property="og:image" content="<%=ogImage%>" />
.....
......
<meta http-equiv="refresh" content="0; url=<%=origialUrl%>" />
//dont use redirect.. facebook dont allow 302...
</head>
<body></body>
</html>
for example xxx.com/#!/en/153 page will share xxx.com/rotator.asp?lang=en&id=153

Templating HTML programmatically

In order to simply create templates for HTML pages (no PHP, no ASPX etc), I need the ability to build up HTML page-chunks that I could then assemble to form a complete HTML page.
So that when I need adding a new menu item, I can re-assemble all the pages with the changed menu-chunk.
I tried W3C's Amaya, and got it fatal error on 1st attempt! Yes, it's W3C and it's a bug pot lol.
Komposer's outdated version had a templating model, but not in the new version.
Since I can't find any "honest" open source website editor to do that, I think I will try this as a solution:
Use c# of VB .NET to build a database out of all HTML chunks.
Create very simplistic web pages with chunk names as comments, like:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>A title here</title>
</head>
<body>
<!-- menu_chunk12 -->
<!-- body1_chunk -->
<!-- footer3_chunk -->
</body>
</html>
When some chunk is edited, I just click a button and my little app will rebuild all the web pages and I'll re-publish them upload to the server.
What do you guru guys think about that?
This is not a terrible approach, but I would probably use some special notation in the comments like <!-- #include(chunk_name) --> so that these special comments are distinguished from regular comments.
You might also look at something like htp.
It's an interesting idea, but in my opinion, if you want a little more extensibility, look into doing XSLT tranformations into HTML. This would provide you a very homogeneous design, that would work on any platform serving HTML, and provide you with a complexity level you desire (simple or extreme).
Yes. I wrote a very simple but effective preprocesor for html that does this.
I used an extremely simple format where "##" was used to introduce a command. The most useful command was "##include " which caused another file's contents to be inserted in place of the include command.
Other useful commands would allow me to set variables, increment variables, and emit the value from a variable into the HTML output. These allow you to add things like a copyright date on all your pages and simply update it easily in a single ##included location.
It's a trivial program to write, and you have full power over the features.
I used this for about 10 years until I pretty much switched from html to php.

Resources