Documentation >> Outline of How-To Docs >> Syndicate Your Weblog with Javascript
Syndicate Your Weblog with Javascript
This page explains how to syndicate your weblog in a way that allows ANY site to use it. This is the only approach I know of that doesn't require special software on the other server (the server that houses the site that uses the syndicated content), such as RSS, ScriptingNews format, or ICE. It works because the format of the file we'll create here is javascript, and it processed by the browser... the other server never even knows about it.
Some of the steps in these instructions are flexible (especially the template editing step, #9), some are less flexible. Feel free to experiment, and if you come up with something really creative, please let us know!
By the way, I have proof that this works. I've created my own ugly-but-functional version. Seeing it in action might be a good way to get started. Create a new HTML document on your desktop, or in your Conversant site (it doesn't matter). Now, in the body of the page, put this script tag:
<script src="http://truerwords.free-conversant.com/journalSyndication.js"></script>
Now load that page into your browser. Voila! You now have TruerWords content in a separate web page. What's cooler than that (besides doing the same thing with your own content)?
The Instructions
- Go to your conversation's template editor
http://your.site.com/url/admin/conversations/yourSiteName/templates
-
Create a new template named "contentOnly", and whose type is "Full Page". It should contain only one line
which says exactly this:
<!--#pageContent-->
-
Save the template.
-
Click on "structure" in the navigation bar on the left.
-
Under "Add New Items", and next to "Add New File", type the name of a new
file. I used "journalSyndication.js", but you can use whatever you want (the
rest of my instructions will assume that this is what you use). Select
"WeblogView" from the "type" popup menu, and click on "Add File"
-
In the list of pages (below the page-creation form), click on the name of the
page you just created (journalSyndication.js), to open the properties editor for
that page.
-
Change the following settings (you're looking at the first tabbed panel,
"Basic"):
- template to "ContentOnly"
(to use the new template on this page)
- stylesheet to "None"
(you don't want a stylesheet associated with your js page)
- javascript to "None"
(you don't want a secondary javascript associated with your js page)
- MIMEtype to "application/x-javascript" or "text/javascript"
(you want the server to tell the browser that the page is javascript)
- MagicNavbar1, 2, and 3 to "None"
... then click on "Save Changes"
-
Click on the "Options" tab, and change just the "Weblog to view" setting to
"Index". This tells the server that you want this page to pull content from the
weblog that can be found in your index page. Click on "Save Changes"
-
Click on the "Templates" tab, and make the following changes:
- Change the day template to say ONLY "<!--#weblogdaytext-->"
(this means that there won't be anything separating the
entries from different days, you can change that if you want to,
but whatever you put there must be valid javascript and/or macros)
- Change the Item Template to look like this:
document.write( "<h4 class='syndHeadlineText'>" );
document.write( "<!--#msgSubject msgNum="<!--#msgNum-->"-->" );
document.write( "</h4>" );
document.write( "<p class='syndBodytext'>" );
document.write( "<!--#msgBody msgNum="<!--#msgNum-->" clipLength="100"
autoParagraphs="false" entify="true"-->" ); (those two lines belong together)
document.write( "</p>" );
The first line writes out the subject enclosed with <h4> tags. The second line writes out -approximately- the first 100 characters of the item's body text. This is the step that you customize to your heart's content, just remember that you're writing javascript here, not pure HTML. Virtually every line should be a document.write( ) command.
- if your Item Template contains one or more empty lines, like in the example above, you must remove the <p> tag from the field labelled "text to insert between dual carriage returns", or it would lead to a javascript error.
- click on "Save Changes"
-
Edit the HTML document (or message) that we created at the beginning, and change the javascript tag to this:
<script src="http://your.site.com/url/journalSyndication.js"></script>
Save it, and open it in your browser.
You're all done, now you can offer a syndicated version of your weblog to any site.
Good luck!
View in DG
|