[View] [Edit] [Lock] [References] [Attachments] [History] [Home] [Changes] [Search] [Help]
api[panoramio] code templates
Object
subclass: #PanoramioTemplate
instanceVariableNames:
' name user group tag set order '
,' width height bgcolor '
,' columns rows orientation ' "valid only for list"
,' list_size position ' "valid only for photoList"
,' delay ' "valid only for slideshow"
category: 'PanoTemplate'!
PanoramioTemplate comment: '
Root of Panoramio Templates framework.
http://www.panoramio.com/api/data/api.html (HTML Templates)
@2012 Alejandro Reimondo - [email protected]
Embedding Panoramio APPs in your page
http://www.panoramio.com/wapi/template/name.html?option&option&option...
'!
! PanoramioTemplate methodsFor: 'HTML' !
url
" Return the URl of the receiver. "
^'http://www.panoramio.com/wapi/template/'
, self nameURL
, self argumentsURL! !
! PanoramioTemplate methodsFor: 'HTML' !
iframe
" Return the HTML code for embedding the receiver in an iframe. "
^self iframe: #right margin: '10px' with: self defaultSettings! !
! PanoramioTemplate methodsFor: 'HTML' !
iframe: floatSelector margin: margin with: settings
" Return the HTML code for embedding the receiver in an iframe. "
^self
iframeStyle:
' style="'
,' float:' ,floatSelector ,';'
,' margin: ',margin ,'"'
with: settings! !
! PanoramioTemplate methodsFor: 'HTML' !
iframeStyle: style with: settings
" Return the HTML code for embedding the receiver in an iframe. "
style isNil ifTrue: [ ^self iframeStyle: '' with: settings ].
settings isNil ifTrue: [ ^self iframeStyle: style with: '' ].
^'<iframe '
, style
,' src="',self url
,'"',settings,'>'! !
! PanoramioTemplate methodsFor: 'private' !
defaultSettings
" Private - Return the defalt settings to be used when embedding the receiver.
The values are obtained from receiver's instances and/or default API vcalues.
"
| defaults value |
defaults := ' frameborder="0" scrolling="no" marginwidth="0" marginheight="0" '.
^#( #(width 280)
#(height 140)
) inject: defaults into: [:total :each|
value := self instVarAt: each first.
value isNil ifTrue: [ value := each last ].
total , ' ' ,each first , '="', value asString,'"'
]! !
! PanoramioTemplate methodsFor: 'private' !
nameURL
" Private - Return the name part of the receiver. "
^self name ,'.html'! !
! PanoramioTemplate methodsFor: 'private' !
argumentsURL
" Private - Return the arguments part of the receiver. "
| args |
self user. "ensure user is set"
args := ((self class allInstVarNames copyWithout: #name)
collect: [:each| Association key: each value: (self instVarAt: each) ])
select: [:assoc| assoc value notNil ].
^args inject: '' into: [:total :assoc|
total ,(total isEmpty ifTrue: [ $? ] ifFalse: [ $& ])
,(self argument: assoc)
]! !
! PanoramioTemplate methodsFor: 'private' !
argument: assoc
" Private - Return the argument string. "
^assoc key ,'=',assoc value asString! !
! PanoramioTemplate methodsFor: 'accessing' !
name
" Private - Return the name of the receiver. "
name isNil ifTrue: [ self list ].
^name! !
! PanoramioTemplate methodsFor: 'mode' !
photo
" Set the receiver to this mode of operation. "
name := #photo! !
! PanoramioTemplate methodsFor: 'mode' !
slideshow
" Set the receiver to this mode of operation. "
name := #slideshow! !
! PanoramioTemplate methodsFor: 'mode' !
list
" Set the receiver to this mode of operation. "
name := #list! !
! PanoramioTemplate methodsFor: 'mode' !
photoList
" Set the receiver to this mode of operation. "
name := 'photo_list'! !
! PanoramioTemplate methodsFor: 'accessing' !
user: userID
" Set the user of the receiver. "
user := userID! !
! PanoramioTemplate methodsFor: 'accessing' !
user
" Return the user of the receiver. "
user isNil ifTrue: [ self user: 592876 ].
^user! !
! PanoramioTemplate methodsFor: 'accessing' !
group: groupId
" Set the group of the receiver. "
group := groupID! !
! PanoramioTemplate methodsFor: 'accessing' !
group
" Return the group of the receiver. "
^group! !
! PanoramioTemplate methodsFor: 'accessing' !
tag: aTag
" Set the tag of the receiver. "
tag := aTag! !
! PanoramioTemplate methodsFor: 'accessing' !
tag
" Return the tag of the receiver. "
^tag! !
! PanoramioTemplate methodsFor: 'accessing' !
set
" Return the set of the receiver. "
^set! !
! PanoramioTemplate methodsFor: 'accessing' !
set: aSet
" Set the set of the receiver. "
set := aSet! !
! PanoramioTemplate methodsFor: 'selecting' !
all
" Set the set of the receiver. "
self set: #all! !
! PanoramioTemplate methodsFor: 'selecting' !
public
" Set the set of the receiver. "
self set: #public! !
! PanoramioTemplate methodsFor: 'selecting' !
recent
" Set the set of the receiver. "
self set: #recent! !
! PanoramioTemplate methodsFor: 'accessing' !
order
" Return the order of the receiver. "
^order! !
! PanoramioTemplate methodsFor: 'accessing' !
order: dateDesc
" Set the order of the receiver. "
order := dateDesc! !
! PanoramioTemplate methodsFor: 'accessing' !
width
" Return the width of the receiver. "
^width! !
! PanoramioTemplate methodsFor: 'accessing' !
width: aNumber
" Set the width of the receiver. "
width := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
height
" Return the height of the receiver. "
^height! !
! PanoramioTemplate methodsFor: 'accessing' !
height: aNumber
" Set the height of the receiver. "
height := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
bgcolor
" Return the bgcolor of the receiver. "
^bgcolor! !
! PanoramioTemplate methodsFor: 'accessing' !
bgcolor: aWebColor
" Set the bgcolor of the receiver. "
bgcolor := aWebColor! !
! PanoramioTemplate methodsFor: 'accessing' !
columns
" Return the columns of the receiver. "
^columns! !
! PanoramioTemplate methodsFor: 'accessing' !
columns: aNumber
" Set the height of the receiver. "
columns := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
rows
" Return the rows of the receiver. "
^rows! !
! PanoramioTemplate methodsFor: 'accessing' !
rows: aNumber
" Set the rows of the receiver. "
rows := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
orientation
" Return the orientation of the receiver. "
^orientation! !
! PanoramioTemplate methodsFor: 'accessing' !
orientation: anOrientation
" Set the orientation of the receiver. "
orientation := anOrientation! !
! PanoramioTemplate methodsFor: 'accessing' !
horizontal
" Set the receiver to this mode. "
orientation := #horizontal! !
! PanoramioTemplate methodsFor: 'accessing' !
vertical
" Set the receiver to this mode. "
orientation := #vertical! !
! PanoramioTemplate methodsFor: 'accessing' !
listSize
" Return the listSize of the receiver. "
^list_size! !
! PanoramioTemplate methodsFor: 'accessing' !
listSize: aNumber
" Set the listSize of the receiver. "
list_size := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
position
" Return the position of the receiver. "
^position! !
! PanoramioTemplate methodsFor: 'accessing' !
position: aPosition
" Set the position of the receiver. "
position := aPosition! !
! PanoramioTemplate methodsFor: 'accessing' !
left
" Set the relative position of the receiver. "
position := #left! !
! PanoramioTemplate methodsFor: 'accessing' !
top
" Set the relative position of the receiver. "
position := #top! !
! PanoramioTemplate methodsFor: 'accessing' !
right
" Set the relative position of the receiver. "
position := #right! !
! PanoramioTemplate methodsFor: 'accessing' !
bottom
" Set the relative position of the receiver. "
position := #bottom! !
! PanoramioTemplate methodsFor: 'accessing' !
delay
" Return the delay of the receiver. "
^delay! !
! PanoramioTemplate methodsFor: 'accessing' !
delay: aNumber
" Set the delay of the receiver. "
delay := aNumber! !
! PanoramioTemplate methodsFor: 'accessing' !
extent: aPoint
" Set the extent of the receiver. "
self width: aPoint x; height: aPoint y. ! !
! PanoramioTemplate methodsFor: 'accessing' !
rows: y columns: x
" Set the rows@columns of the receiver. "
self rows: y; columns: x. ! !
"---- sample expressions ---------------------------------"
! PanoramioTemplate class methodsFor: 'sample' !
sample
" Return a sample instance of the receiver. "
^self sampleList! !
! PanoramioTemplate class methodsFor: 'sample' !
sampleList
" Return a sample instance of the receiver. "
| columns width |
columns := 4. width := 280.
[ columns := DOM window innerWidth // 52 - 3 max: columns.
width := columns * 60.
] on: Error do: [ "nothing" ].
^self new
list;
extent: width @ 140;
rows: 2 columns: columns;
horizontal;
yourself! !
! PanoramioTemplate class methodsFor: 'sample' !
samplePhoto
" Return a sample instance of the receiver. "
^self new
photo;
extent: 400 @ 300;
yourself! !
! PanoramioTemplate class methodsFor: 'sample' !
sampleSlideshow
" Return a sample instance of the receiver. "
^self new
slideshow;
extent: 450 @ 400;
delay: 6.5;
yourself! !
! PanoramioTemplate class methodsFor: 'sample' !
samplePhotoList
" Return a sample instance of the receiver. "
^self new
photoList;
extent: 500 @ 500;
listSize: 8; bottom;
yourself! !