felixhageloh / uebersicht

ˈyːbɐˌzɪçt
GNU General Public License v3.0
4.6k stars 165 forks source link

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

Closed jimmyhartington closed 2 years ago

jimmyhartington commented 2 years ago

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>
"""
jimmyhartington commented 2 years ago

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"

neoswallow commented 2 years ago

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

jimmyhartington commented 2 years ago

I do not know how to do that.

neoswallow commented 2 years ago

Try:

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

Thanks. That seems to work consistantly.