RevIgniter - Loading Images

2011-03-24 Thread Sivakatirswami
 Robert I changed the thread title since we are on now from kudos to 
implementation


On 3/23/11 11:19 PM, Robert Mann wrote:

I too found revIGniter a fantastic working work! and pointed that out several
time.

My first site using that though has to be reworked from a speed point of
view because I chose to view pictures with a javascript gallery module that
loads every files at start up... and that also made the cache function of
revIgniter out in the limbs, (does not work in that case). So I'll drop
that.

www.le-saint-claire.com


Robert, here is my simple function to drive a random selection from a 
folder of images, the image is loaded once on page load and does not 
change until next page load. this may not be what you want...


I so very rarely  share anything because I don't trust that anything I 
do is professional enough to share...but in case it helps:


I use the assets helper and cache busting and have far future headers 
set to 1 year on your server. regular viewers will gradually cache the 
images and there will be zero download.. (unless they empty their cache 
of course)


Also because the rigImageAsset delivers a fully qualified img src=* 
string we have to strip it back to a plain URL for use inside a CSS 
background.


As always (I keep forgetting) all functions called have to be on top.

Once I figure out how to do it, I'll probably make my own
rigImageAssetURL  helper and load these in base config and get them out 
of my controllers.


function getImageURLString pTaggedImage
   set the itemdel to quote
   return item 2 of pTaggedImage
end getImageURLString

function rotateMastheadBackground
   set the defaultFolder to 
/home/devhap/public_html/assets/img/masthead/rotation/

   put the files into tBackgrounds
   put line (random (the number of lines of tBackgrounds)) of 
tBackgrounds into tBackground

   put (masthead/rotation/  tBackground) into tBackGroundPath
   put (rigImageAsset(tBackGroundPath,,,TRUE))  into pTaggedImage
   return getImageURLString (pTaggedImage)
end rotateMastheadBackground


Then in the controller call the image into the variable

command index

 # like this:
 put rotateMastheadBackground() into gData[mastheadBackground]

 put rigImageAsset(masthead/KHM-logo.png,,,TRUE) into 
gData[khmLogo]

put rigCssAsset(books.css,,,TRUE) into gData[booksCSS]

# SET PAGE TITLE
put Books by Himalayan Academy into gData[pageTitle]

# LOAD THE VIEW FILE
get rigLoadView(sitewide/head)
get rigLoadView(books/books-masthead)
get rigLoadView(sitewide/main-nav)
get rigLoadView(books/books-main-content)
get rigLoadView(books/books-bottom-content)
#get rigLoadView(sitewide/bottom-nav)
get rigLoadView(sitewide/footer)
end index


the only caveat of this is that rigImageAsset can only poke variables in 
views, but not in CSS files. So you have to do a little hokey bit by 
putting this in the top of your view:


[[gData[booksCSS] ]]

style type=text/css title=masthead media=screen
#masthead{
 height:100px;
background-image: url('[[gData[mastheadBackground] ]]');
background-repeat: no-repeat;
}
/style

/head
body
div id=page-container

 # Use this to poke a top div if you want to run a big announcement
# across the top of the page; where you push a view as data in your 
controller:


[[gData[siteWideBanner] ]]


div id=masthead
div id=khm-logo
[[gData[khmLogo] ]]
/div
/div!-- masthead --

This actually turned out to be a serendipity advantage because it forced 
me to close the head of the document in the masthead view. I normally 
don't like to break the DOM like this, (head opens in one view and 
closes in another) but in the end I realized it didn't matter since by 
design the masthead div will always lead the page. This sudden lead me 
to realize I could separate the core CSS for the site and the 
dynamically load an override CSS for a particular area that used a 
particular masthead view.  So, one masthead view could call a different 
CSS: magically, then  the head of the web pages for


/books

can be different from

/children

etc.  and you just keep your logo the same throughout.

I plan move away from the random selection and set up different folders 
with series of like images   e.g. all flowers, in one, all people in 
another, all kids cool images in another  and order them by file name, 
then the function will write a session var to a file indicating what 
header image is currently loading. All viewers will then see the same 
image at the same time, and the function will steps thru, e.g. a whole 
series of rainbow pix.


And if I want to insert things on top of the masthead you can just put 
vars in the mast head and fill them with views. fantastic!


I'm blabbering  on and on here.

POINT: this is just way too much fun, way too easy with LiveCode.. 
imagine doing this in PHP.

Well I can't, because I don't know PHP...

10 minutes of cut and paste lines and controller handlers and magically 
now we 

Re: RevIgniter - Loading Images

2011-03-24 Thread Robert Mann

Robert, here is my simple function to drive a random selection from a 
folder of images, the image is loaded once on page load and does not 
change until next page load. this may not be what you want... 

Many thanks its exactly what I was going to program : a random selection of
an image for each page call! I did not grasp the way it you did that in 5
seconds but will dig it next week, and let know and share handlers to do
that!

It would be nice to have a respository of revIgniter compatible handlers
somewhere. Maybe the best place is on rev lessons!? Because it needs a
little explanation also! 






--
View this message in context: 
http://runtime-revolution.278305.n4.nabble.com/RevIgniter-is-Fabulous-tp3401600p3404321.html
Sent from the Revolution - User mailing list archive at Nabble.com.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode



Re: RevIgniter - Loading Images

2011-03-24 Thread Web Admin Himalayan Academy

 On 3/24/11 4:51 PM, Robert Mann wrote:

Robert, here is my simple function to drive a random selection from a
folder of images, the image is loaded once on page load and does not
change until next page load. this may not be what you want... 

Many thanks its exactly what I was going to program : a random selection of
an image for each page call! I did not grasp the way it you did that in 5
seconds but will dig it next week, and let know and share handlers to do
that!

[warning, if you are not familiar with apache future expires header
and caching performance issues, the following may be all ZULU to you.]

Just remember once you finish the testing to set the cache busting to 
false in my code I should have made that clear.


(I assume you have far future expires headers set on your server, you 
can do this with .htaccess of your site if you don't have access to the 
core httpd.conf...just put  this in your .htaccess file:


ExpiresActive On
ExpiresDefault access plus 10 years


see http://developer.yahoo.com/blogs/ydn/posts/2007/05/high_performanc_2/

for details

e.g. when developing do this:

put rigCssAsset(ha-new.css,,,TRUE) into gData[haNewCSS] # Load Base 
Styles


when you stop changing your css and you know you are not going to change 
anything for a while then


put rigCssAsset(ha-new.css,,,FALSE) into gData[haNewCSS] # Load Base 
Styles


and change:

   put (rigImageAsset(tBackGroundPath,,,TRUE))  into pTaggedImage

to

   put (rigImageAsset(tBackGroundPath,,,FALSE))  into pTaggedImage

Later if you start developing again and you find things are not updating 
as you work, instead of having to go empty the cache all the time, just 
set these back to TRUE   actually for certain sets of images there's 
hardly any reason use TRUE because the likelihood that i would put up a 
different version of waialeale-sunset-dcsn6463.jpg with the same name 
if very unlikely...


But if your content designers start throwing different versions of 
masthead.jpg onto the server every day, they you definitely will want 
to set it to TRUE  so that they will see their new image come up as they 
test...otherwise they will come crying to you that they never see their 
new baby on the screen and it keeps showing yesterdays' version of 
masthead.jpg



It would be nice to have a respository of revIgniter compatible handlers
somewhere. Maybe the best place is on rev lessons!? Because it needs a
little explanation also!


Agreed! Not sure what is best.  Happy to contribute moving forward... I 
think best would be a blog on Ralf site to guard against fragmentation.






___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode