felixhageloh / uebersicht

ˈyːbɐˌzɪçt

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Widget to display image from web-server does not update image

jimmyhartington opened this issue · comments

I have a simple widget to display an image from a webcam.
The image is located on a web-server I control and is always called the same name.
Is overwritten every minute by my camera.

But the widget seems to cache the image, since it has the same name.

Is it possible to have a widget not cache elements?

Widget code:

# Set the refresh frequency (milliseconds) to every hour
refreshFrequency: 10000

style: """

  bottom: 20px				// Position widget
  right: 20px

  widget-align = left
  color: #fff
  font-family Helvetica Neue
  background rgba(255, 255, 255, .1)
  padding 20px 20px 20px 20px
  border-radius 5px

  #container
    text-align: widget-align
    position: relative
    clear: both

  .ch-image
    max-height: 35vh		// allow the img to use up at most 35% of the desktop's height
    max-width: 50vw		// allow the img to use up at most 50% of the desktop's width

"""

# Render the output.
render: (output) -> """
  <div id='container'>
  <img class="ch-image" src="https://files.skabertrang.dk/jh/webcams/serverrum/image.jpg">
  <div>
"""

If I use the menu command "Refresh All Widgets" the image updates.
If I use an AppleScript to just refresh this widget nothing updates.
tell application id "tracesOf.Uebersicht" to refresh widget id "serverroom-widget-index-coffee"

What if you add a query string with a random number so that url changes each time it refreshes?

I do not know how to do that.

Try:

  <img class="ch-image" src="https://files.skabertrang.dk/jk/webcams/serverrum/image.jpg?rnd="""+Math.floor(Math.random() * 999999)+"""">

Thanks. That seems to work consistantly.