Archive | February, 2007

Adding images to a csv-table in restructured text

Anyone who has tried to add images using the csv-table directive in restructured text may have come to the following conclusion: it can’t be done. Well certainly not using any of the existing attributes or syntax for tables (an oversight?), but it can be done with the replacement directive.

Firstly, a csv-table in restructured text looks like this:

Currently Held Records
No Category Details Record Date Photo
1 Somersaulting Longest continuous distance 12 miles 390 yards Apr 1986 green_face.jpg

And would created with the following code:

.. csv-table:: Currently Held Records
  :header: "No", "Category", "Details", "Record", "Date", "Photo"
  :widths: 42, 270, 270, 220, 119, 119

  1, "**Somersaulting**", "Longest continuous distance", "12 miles 390 yards", "Apr 1986", |green_face.jpg|

Ignore the first three lines—it’s the table structure info, similar to the way you would define an image, but instead defining table column titles and widths. Should be pretty obvious how to change anything there, but in case not, let’s recap a few csv-table fundamentals, as it is important in restructed text that formatting is followed precisely—right down to the space and comma:

  • a single space after each comma—no other spaces
  • bold text like **this**
  • all text inside "quote marks"
  • numbers don’t need to be in quote marks, unless together with text: "12 miles 390 yards"
  • return at the end of the line

The last line is an example of a row of the table, and more importantly contains the image:

1, "**Somersaulting**", "Longest continuous distance", "12 miles 390 yards", "Apr 1986", |green_face.jpg|

The image is the complex, for “|green_face.jpg|” (without quotes) is actually a “replacement” for the image definition, somewhat akin to an ID in css or a variable in pretty much any programming language you could name.

The image url, link and any other image parametres pointed to by the replacement id then get defined below the table (ie at the bottom of your reSt document):

.. |green_face.jpg| image:: green_face.jpg
  :target: green_face.jpg

Note:

  • The spaces are important as usual, as is putting the info on two lines
  • the name of the replacement/id can be anything, but it makes sense to me to use the image name
  • you can use the same image two times (or more) but only define the replacement once.

Example

You can view an example of a resturctured text csv-table including images here: Ashrita.com

Comments { 0 }

Tips for faster speed in Plone

Plone, like any content management system, has slower page load speeds than static pages. Ensuring a fast enough page load speed so users won’t get turned off is therefore a big concern of Plone site maintainers. Here are some tips:

1. Avoid missing page components

If a part of a page (most commonly an image) returns a 404 or 301, it can slow down the page to more than half the speed. No matter what one does on system level you cannot make up for that kind of speed loss.

301 errors are particularly tricky since it is basically a bad link, but some code (most probably RedirectionTool) finds the requested object somewhere else and redirects the original request to the correct url. The url is served correctly, but that 301 makes the page load slow.

Actually the standard use of RedirectionTool (aliases) has the same effect, so it should be used just temporarily.

The Tamper Data extension (https://addons.mozilla.org/firefox/966/) to Firefox is a great tool because it allows you to quickly inspect headers of all the page components, not only the page itself. After installation, you will be requested to close the browser completely and start it again. Now Open Tamper Data from Tools menu in Firefox, and open a page you want to check out in Firefox. You can now see that Tamper Data window is being populated. Each line is one individual component of the requested page that has to be loaded in order to render the page. The most important column for us
is "Status". We are looking for 404 and 301 errors. 200 means you accessed site content without error and 304 means your local content is the same as in the squid, which is even better.

2. Page content – sometimes less is more

A page with twice as much content will most probably load two times slowly. Understandably that we want put as much possible into every page, but quite often less is more. Things that have to be generated by Zope (smart folders ect) will obviously take longer to load than static content

3. Caching

Most speed improvement on a system level involves caching – storing site content in easily accessible areas. Most large sites run a proxy cache like squid to serve up static content and keep Zope from doing the work. Other static content is cached in the browser itself. The most import thing is to make sure all pages and their components have correct caching headers; this is done by the CacheFu product, which now ships with Plone.

The whole plone caching business is described in http://plone.org/events/regional/nola06/collateral/make-plone-go-fast.pdf and CacheFu product documentation.

Obviously, any caching issue we fix has a double effect. The page is served from cache much faster and it does not create any load on zope server. Then the pages that have to be served by zope (cache refresh, editors) are much faster.

Another crucial point is to evaluate any new feature or product we are going to use from the caching and performance perspectives. Then we should document what adjustments have to be done when a product or a feature is deployed on a particular site. For instance if EasyBlog is installed on a site, the CacheFu will have to be set; if sdot is installed, the CacheFu will have to be set and icon image will have to be created, etc.

(Thanks to Atmasamarpan for all his help with this article)

Comments { 0 }

Benefits of Writing with Lists

The Advantages of Writing in Lists.

  1. Easier to Read. People don’t have time or the interest to read long sections of text. Writing by bullet points or numbers makes it easy to read and skim through. Picking up on the points which look most interesting.
  2. Easier to Write. Writing lists tends to be easier. Writing by bullet points means that you focus on one point at a time. It also tends to encourage simpler writing which is a good habit to encourage.
  3. Discussion. Lists provide an opportunity for discussion. For my next blog post I am going to choose my top 13 books that changed the world. It engages the reader because they start thinking what they would have chosen. If you want people to add comments to your blog this is a good strategy to employ.
  1. Look Authorative Lists have a certain authority. People give a lot of respect to top 10 Bestsellers. If you give top 10 tips for writing a blog, it gives your points an added force.
  2. Grab Attention. People skim read the internet. Surfing the internet is not like reading a book. When you a buy a book you know what you are getting. When you come across an internet page, 95% of people move on after less than 60 seconds. Lists and subheadings are a way to grab people’s attention before they move elsewhere.
  3. Use Bold Text. As well as writing lists it is helpful to use a small amount of bold text. This makes it even clearer what the point is about.

(To create Bold text in reSt use ** Text to be made bold **

  1. Create Content Lists are an easy way of creating content. Top 10 favourite books. Top 7 Reasons to write a blog Top 7 reasons to write lists…

Of course this doesn’t mean you have to write everything by lists. But some subjects work very well through writing by lists.

Comments { 0 }

Interesting Links for building web traffic

Comments { 0 }