Plone/Zope

Getting content from an RSS feed

February 20th, 2005

At http://wiley.ed.usu.edu/index_html/2004092301 David Wiley explains how to parse an RSS feed, extract content from it and render that content as HTML in a page in your Plone site.

His explanation tells you all you need to know. All you then need to do is get feedparser from Sourceforge and install it. I used wget to download it onto my Linux machine, but then found I couldn't unzip it with gunzip. So I had to use WinZip on my Windows PC and then copy the unzipped folder across to the Linux machine via SSH.

The install instructions in the README file are as follows:

To install:
$ python setup.py install

and it really is as simple as that. It works.

I then modified David Wiley's Python script a little (see below) because I wanted to use it for several pages of RSS-fed content. So I took the description out of the Python file (which I called rssfeed.py) and put it in the index.html page template instead. And that was about it. All I had to do then was choose a suitable RSS feed. The one I chose to try out was the list of most popular web pages in the "Programming" category at http://del.icio.us.

You can see the resulting dynamically generated page at www.itauthor.com/programming/popproglinks.
Read the rest of this entry »

Leave a comment

 

Recent items for non-members

February 16th, 2005

My Plone site is a non-member site - i.e. I can log on and change stuff, but everyone else just gets to look. The "Recent Items" portlet that comes with Plone is based on your last login date/time, so it doesn't show up if you aren't logged in.

A simple method for getting a list of recent items that everyone gets to see is very nicely explained at www.zettai.net/Forums/04/1081998202/view.

For a large, high-volume site you'd need to do something a bit smarter to work out the date 2 or 3 weeks ago (or less), but for my purposes using

tal:define="last_login_time python:DateTime('1/1/2005'); ... 

works fine.

Potentially similar posts

Leave a comment



Displaying the 3 As for text sizing

February 9th, 2005

The default Plone skin used to have 3 letter As at the top right corner for text sizing. These have been replaced by the words: "small text", "normal text", "large text" - as you can see at plone.org.

However, I prefer the 3 As and I wanted to use them instead. Simple you might think. I thought so too, but not so. One of the painful things about developing a web site using pages that are dynamically generated by something like Zope/Plone is that you can't look at other people's source and work out what they're doing.

I eventually *did* work out how it was done, but only after hours of trial and error and anguish, that required me piecing back together how the global_siteactions code (in /portal_skins in the ZMI) *used* to look. I did this using the Plone CVS logs on SourceForge. Not nice! I also made use of the Web Developer add-on for Firefox, which makes it easier to see what CSS styles a page is using.

In brief, the secret is to write a custom global_siteactions like this:

<html xmlns="http://www.w3.org/1999/xhtml"
      xml:lang="en"
      lang="en"
      i18n:domain="plone">

<body>
<div metal:define-macro="site_actions"
      id="portal-siteactions"
      tal:define="site_actions actions/site_actions|nothing;
                  getIconFor nocall:putils/getIconFor"
      tal:condition="site_actions">

     <tal:actions repeat="saction site_actions"><a
             href=""
             i18n:attributes="title"
             tal:attributes="href saction/url;
                             style string:background: url($portal_url/$icon);
                             title title;"
             tal:define="title saction/name;
                         icon python:getIconFor('site_actions', saction['id'], None)"
             tal:condition="icon"
            ></a></tal:actions>
</div>
</body>
</html>

You then need to make/edit a custom plone.css stylesheet, removing all the existing styles for portal-siteactions ID styles, and replacing them with this:

#portal-siteactions {
    position: absolute;
    top: 11px;
    right: 16px;
    width: 54px;
    margin: 0;
    padding: 0;
    z-index: 2;
}
#portal-siteactions a {
    display: block;
    float: left;
    padding: 18px 0 0 0;
    width: 18px;
    height: 0px !important;
    height /**/: 18px;
    overflow: hidden;
}

There was lots of other stuff I changed along the way, but I think these were the important changes. I can't guarantee it though because this has taken me hours and hours of late evening work, and I'm too exhausted right now to try and retrace my steps. All to get 3 little As to appear. Would you believe it?

Potentially similar posts

Leave a comment



Preventing visitors from finding users in a search

February 8th, 2005

My Plone site is intended to be view-only to most of the world. So you can come and browse around, but you can't contribute unless I give you a logon. That part was easy to set up, but I also wanted to prevent non-contributors from seeing the Members list or members' pages. It's easy to prevent the Members folder from being displayed, but it's not quite so easy to prevent people from running a site-wide search that will hit on something within the Members area.

I discovered how to do this on the following useful plone.org page:

Limiting Search to Sections of Site
http://plone.org/documentation/howto/how-to-limit-search

This page also reveals (part of) something else I wanted to do. I'd seen on other Plone site (e.g. http://scs.ictp.it/) a search box with a drop-down list that allows you to search sections of the site, or other websites (Amazon, Google, etc). This page shows how to do the site-section part of this.

The relevant sections are:
As done on plone.org by Joel Burton and
Limiting search to a member's folder by Bill Page
Read the rest of this entry »

Leave a comment



Plone URLs without the Plone site ID

February 7th, 2005

I've been chewing this one over for a few weeks now, prodding the Internet for answers whenever I get a spare half hour or so - with no luck, until this evening.

I repeatedly skimmed back and forth through Andy McKay's Definitive Guide to Plone for the answer, but came up with nothing. But eventually I decided to read through Chapter 10 "Integrating with Other Systems" carefully, and this led me to the answer.

Actually, I didn't figure out what I'd been doing wrong from Andy McKay's book (although the answer is in there). In fact, I read through the stuff about creating a Virtual Host Monster to the point where he says "At this point, if you're using a proxy Web server in fron of Plone continue the configuration for that Web server in the 'Configuring the Proxy Server' section." I then decided to take a look at my own VHM.

I discovered that, if you have already created a VHM and, in the Zope Management Interface, you click Root Folder > Virtual Host Monster, you get a helpful "About" page that told me all I needed to know. I quote:

The most common sort of virtual hosting setup is one in which you create a Folder in your Zope root for each domain that you want to serve. For instance http://www.buystuff.com is served from Folder /buystuff.com while http://www.mycause.org is served from /mycause.org.

A single Virtual Host Monster in your Zope root can handle all of your virtual hosting needs. It doesn't matter what Id you give it, as long as nothing else in your site has the same Id.

The VHM doesn't do anything unless it sees one of the following special path elements in a URL: VirtualHostBase sets the protocol and host, while VirtualHostRoot sets the path root.

If the URL path of a request begins with "/VirtualHostBase/http/www.buystuff.com", for instance, then URLs generated by Zope will start with http://www.buystuff.com. Since the port number was not specified, it is left unchanged. If your Zope is running on port 8080, and you want generated URLs not to include this port number, you must use "/VirtualHostBase/http/www.buystuff.com:80".

If the URL contains VirtualHostRoot, then all path elements up to that point are removed from generated URLs. For instance, a request with path "/a/b/c/VirtualHostRoot/d" will traverse "a/b/c/d" and then generate a URL with path /d.

Visitors to your site don't see these special names, of course. You insert them into the path using either an external rewriter, such as an Apache RewriteRule or ProxyPass directive, or by setting up a mapping on the "Mappings" tab.

For example, suppose Zope is running on port 8080 behind an Apache running on port 80. You place a Virtual Host Monster in the Zope root Folder, and use Apache to rewrite "/(.*)" to http://localhost:8080/VirtualHostBase/http/www.buystuff.
com:80/buystuff.com/VirtualHostRoot/$1
.
(Note: this is one long line.)

You could get the same effect in a standalone Zope by adding the line www.buystuff.com/buystuff.com to the "Mappings" tab. In either case, requests for http://www.buystuff.com/anything will look for Zope object /buystuff.com/anything.

A quick look in my httpd.conf file and it became clear what my problem had been. I had:

RewriteRule ^(.*) http://localhost:8080/VirtualHostBase/http/www.itauthor.com:80/
VirtualHostRoot/plone$1 [L,P]

When I should have had:

RewriteRule ^/(.*) http://localhost:8080/VirtualHostBase/http/www.itauthor.com:80/
plone/VirtualHostRoot/$1 [L,P]

plone was in the wrong place!
Read the rest of this entry »

Leave a comment



^ back to top ^

Page 2 of 3123