Youtube SPFJS dynamic nav - php

Basically I am trying to implement the youtube spfjs (
https://youtube.github.io/spfjs/documentation/start/) dynamic navigation with progress bar.
I need a php/jquery version of this ruby solution -http://lorefnon.me/2015/11/26/boost-your-content-focussed-site-with-structured-page-fragments.html
Having issues handling the ?spf=navigate request and returning json files etc. My json file contents isnt loading over the initial page contents.
I've had a look through all online docs etc but really limited information currently out there. Hopefully this will help quite a few people as it seems an awesome framework. Thanks

Related

create a content-only page for mobile news feed in modx

I've been tasked with providing the backend for a news feed that will be used by our company apps. The feed will pull articles from our current website, which is built with ModX (evolution). So far, I've designed the feed to send JSON through a specified url containing the needed information. It's currently in the following format (using Ditto placeholders):
{
"title":"[+longtitle+]",
"description":"[+description+]",
"link":"[(site_url)][~[+id+]~]"
},
Here's my issue - the link I'm providing through the JSON (in the link tag) opens the full, desktop version of the page. Our current site is not responsive, and was not originally designed to handle mobile devices. We would like to open a small, clean page showing ONLY the ['content'] of that particular article. I'm looking for a way to link to a page showing only this content - no header, no footer, nothing.
I know that I could create a new page to handle all of this, but it needs to be dynamic. New articles are created regularly, and I'd like to avoid having to add another page to handle this for every article, while also making it simple for the writing team to integrate this feature.
One of my ideas so far is:
Pass a GET parameter to the URL "link" in the JSON - something like - www.mysite.com/article1?contentOnly=true. Then, in my article, detect this parameter in PHP and handle accordingly. I would need this snippet on each article written, so it may cause issues down the road if our staff writers forget to add it.
I haven't worked with ModX long, so I'm assuming there's a better way to handle this. Any ideas would be greatly appreciated. Please let me know if I need to provide more information.
I am not 100 % sure how you have done this, but here's my tip.
Don't use the resource itself to output the JSON. Doing this based on a GET-paramter will required the entire site to be uncached. Instead, use a single resource for the feed and supply the id/permalink there.
For example: mysite.com/feed?id=1, mysite.com/feed?latest or something like that.
Done this way, you could have an empty template with just the snippet that is parsing to JSON in it. This has to be uncached of course, but the rest of the site could be cached as normal.

Rendering a pdf/ppt document in a jquery mobile web page

I am developing a jquery-mobile learning portal. And i would like to render pdf and ppt documents like slideshare does or google books. i have tried lloking around but i can't seem to get any API that can enable me do that. I saw PDF.js but it seems too heavy for mobile and besides it requires a lot of work styling it.
Any assistance ... will be appreciated
Have you checked out Scribd's API?

How to implement a backend with AJAX, PHP, and MySQL for dynamic video sources when using Google TV Templates?

For people interested in doing web apps for Google TV, especially those with video content, the easiest way is use Google TV Templates: https://developers.google.com/tv/web/docs/gtv-templates.
The original Google TV Templates were developed with video source files hard coded in Javascript file. A number of people have asked about how to implement a backend with PHP and MySQL and store video sources there so that they can be dynamically loaded from frontend within the Templates. The following article was written to address this question.
https://developers.google.com/tv/web/docs/ajax_gtv_templates_tutorial
The tutorial walks you through how to set up a database in MySQL (i.e. schema, sample data), PHP code to serve data, and modified Javascript to do AJAX loading.
Currently to add video source data into the database, one can use straight SQL but it may be more desirable to build a PHP admin front end.
A bug was recently reported by Maurizio on Google TV Developers +page: https://plus.google.com/117492290125593364976/posts:
"Hi, i downloaded the html5 template mysql version. it is working fine but if i add more than one category , the last one added is repeted. Do u have any idea of how i can fix this problem? many thanks."
I'll follow up with a fix.
A fix to this bug is available and a new download is at: http://gtv-resources.googlecode.com/files/gtv_template2_ajax_php_mysql.tgz
The actual fix is in this php file:
http://code.google.com/p/gtv-resources/source/browse/trunk/gtv_template2_ajax_php_mysql/videosources.php
If there is interest, please ask a question and I'll write up an admin page as well.

Need help with google's search feature of pre-displaying the website

I have been thinking about this new( I know it has been a while ;p) google's feature that displays the website in the search result.
What i don't kind of get is, how they did it? Is it a form of iframe? or is it a php render of the page? Is it dynamic JavaScript/Ajax? I am just very curious how they have done it? And the follow up question would it possible for us to duplicate for our own sites? Like a search result page to display the page on mouse hover.
Any assistance would be most appreciated? I searched everywhere i could not get a definite answer anywhere?
The thumbnail is rendered by some kind of browser engine, and stored in an image file. There are lots of providers of this service, for example Thumbshots, WebSnapr and ShrinkTheWeb.
It is a thumbnail rendered on server side, and stored in an image file.
There are questions on SO dealing with how to do this, e.g.:
How can I generate a screenshot of a webpage using a server-side script?
How can I take a screenshot of a website with PHP and GD?
How might I obtain a Snapshot or Thumbnail of a web page using PHP?

Facebook Feed (RSS using PHP)

Can someone tell me what happens when i enter a link into the Facebook Status Update Form and it loads up a mini info kinda thing of the website (I'm guessing its RSS or something?)
How do i implement this on my site using PHP?
What do i need to learn to be able to implement that?
It scrapes the page you are linking to. It doesn't have anything to do with RSS.
By looking at the HTML of the page it can get the page title for you and find all the images that can be used as a thumbnail.
Take a look at HTTP or cURL in the PHP manual for methods to get webpage content.

Categories