Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 193
- Log:
First stage commit of Typo 4.1, modified for the ROOL site.
Includes all local modifications but a final pass needs to be
made to delete any files left over from earlier Typo versions
that shouldn't be here anymore. See the 'tags' section of the
repository for a clean Typo 4.1 tree.Note that symlinks to shared files in the RISC OS Open theme
directory have been deliberately included this time around; I
decided that on balance it was better to leave them in as
placeholders, since unlike symlinks in app/views/shared, the
Typo theme structure is not a standard Rails concept.
- Author:
- rool
- Date:
- Wed Apr 04 18:51:02 +0100 2007
- Size:
- 3178 Bytes
1 | require 'net/http' |
2 | require 'flickr/flickr' |
3 | |
4 | class Typo |
5 | class Textfilter |
6 | class Flickr < TextFilterPlugin::MacroPost |
7 | plugin_display_name "Flickr" |
8 | plugin_description "Automatically generate image tags for Flickr images" |
9 | |
10 | def self.help_text |
11 | %{ |
12 | You can use `<typo:flickr>` to display images from [Flickr](http://flickr.com). Example: |
13 | |
14 | <typo:flickr img="31367273" size="small"/> |
15 | |
16 | will produce an `<img>` tag showing image number 31367273 from Flickr. This image will be linked to |
17 | the Flickr page for this image, so you can zoom in and see larger versions. It will also have a |
18 | comment block attached if a description has been attached to the picture in Flickr. |
19 | |
20 | This macro takes a number of parameters: |
21 | |
22 | * **img** The Flickr image ID of the picture that you wish to use. This shows up in the URL whenever |
23 | you're viewing a picture in Flickr; for example, the image ID for <http://flickr.com/photos/scottlaird/31367273> |
24 | is 31367273. |
25 | * **size** The image size that you'd like to display. Options are: |
26 | * square (75x75) |
27 | * thumbnail (maximum size 100 pixels) |
28 | * small (maximum size 240 pixels) |
29 | * medium (maximum size 500 pixels) |
30 | * large (maximum size 1024 pixels) |
31 | * original |
32 | * **style** This is passed through to the enclosing `<div>` that this macro generates. To float the flickr |
33 | image on the right, use `style="float:right"`. |
34 | * **caption** The caption displayed below the image. By default, this is Flickr's description of the image. |
35 | to disable, use `caption=""`. |
36 | * **title** The tooltip title associated with the image. Defaults to Flickr's image title. |
37 | * **alt** The alt text associated with the image. By default, this is the same as the title. |
38 | } |
39 | end |
40 | |
41 | def self.macrofilter(blog,content,attrib,params,text="") |
42 | img = attrib['img'] |
43 | size = attrib['size'] || "square" |
44 | style = attrib['style'] |
45 | caption = attrib['caption'] |
46 | title = attrib['title'] |
47 | alt = attrib['alt'] |
48 | |
49 | begin |
50 | flickr = ::Flickr.new(FLICKR_KEY) |
51 | flickrimage = ::Flickr::Photo.new(img) |
52 | sizes = flickrimage.sizes |
53 | |
54 | details = sizes.find {|s| s['label'].downcase == size.downcase } || sizes.first |
55 | width = details['width'] |
56 | height = details['height'] |
57 | imageurl = details['source'] |
58 | imagelink = flickrimage.url |
59 | |
60 | caption ||= sanitize(CGI.unescapeHTML(flickrimage.description)) unless flickrimage.description.blank? |
61 | title ||= flickrimage.title |
62 | alt ||= title |
63 | |
64 | if(caption.blank?) |
65 | captioncode="" |
66 | else |
67 | captioncode = "<p class=\"caption\" style=\"width:#{width}px\">#{caption}</p>" |
68 | end |
69 | |
70 | "<div style=\"#{style}\" class=\"flickrplugin\"><a href=\"#{imagelink}\"><img src=\"#{imageurl}\" width=\"#{width}\" height=\"#{height}\" alt=\"#{alt}\" title=\"#{title}\"/></a>#{captioncode}</div>" |
71 | |
72 | rescue Exception => e |
73 | logger.info e |
74 | %{<div class='broken_flickr_link'>`#{img}' could not be displayed because: <br />#{e}</div>} |
75 | end |
76 | end |
77 | end |
78 | end |
79 | end |