Page 1 of 2

CR or LF on a control page question

PostPosted: Sun Aug 13, 2017 11:06 am
by norcoscia
Hi, I have a control page that lists the current forecast for my area - the problem is, the message text is sometimes short (a word or two) and sometimes it might be 10 words. Is there a way to have the message wrap so I can display it in a given size, say two or three lines vice one very very long horizontal line?

Thanks for any help...

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 3:56 am
by DaveL17
The Matplotlib plugin has a multi line text device type that might work for you, and I also have one or two example scripts to display multi line text in my plugin forum.


Sent from my iPhone using Tapatalk

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 5:41 am
by norcoscia
Thanks Dave - I try messing with those today :D

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 5:45 am
by DaveL17
Let me know if you have any questions. The script thread may be a little tough to find, so here's a link:
http://forums.indigodomo.com/viewtopic.php?f=149&t=13908&hilit=multiline+text

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 10:58 am
by norcoscia
Well, that turned out to be too hard for my small brain, but that is OK - On the up side, it did get me looking at your fantastic WUnderground plug-in.

Wow, thanks so much for providing it. I do have a question on it - I was wondering if it is possible to pull down a completed image like the one below - vice trying to build it from scratch from the WUnderground components. Thanks again....

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 11:13 am
by Different Computers
That really comes down to whether hot linking is blocked on the site you're trying to get the image from, and whether it's dynamically generated.

If you can right click and choose to load the image from the original website in a new tab of it's own, you can just place the resulting URL in your control page. If it's dynamically generated and you can figure out the format of the dynamic generation, then you could use various programmatic substitutions and the Dynamic Refreshing URL plugin to display it.

(I just looked at that image live on wunderground.com, and it is NOT a graphic in the URL sense.)

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 11:24 am
by DaveL17
The WUnderground plugin has a satellite image downloader device that could work for this purpose, but there are many ways to skin this particular cat. If you can get an underlying URL for the image, you may just be able to use Indigo's native control page tool for refreshing URLs.

The plugin doesn't have any built-in capability to construct images like the one you're after.

Hope you enjoy the plugin.


Sent from my iPhone using Tapatalk

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 11:32 am
by norcoscia
I know - I wish it was a URL - I'll look at the satellite image downloader - thanks again for the plug-in....

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 11:50 am
by DaveL17
If it's not a URL, then the satellite image downloader isn't going to help I'm afraid.


Sent from my iPhone using Tapatalk

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 11:54 am
by norcoscia
Yes - I just looked at it -- not a PNG either - Looks like this too hard also :-(

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 12:43 pm
by roussell
It's not that hard. I use web2png to convert a section of a webpage from dark sky.net to a png and store that for my control pages. Install webkit2png using brew.

Since the resultant page will likely have more info on it than I want, I embed the page in an iframe and chop down the iframe to the dimensions I want.

Code: Select all
<!DOCTYPE html>
<html>
<head>
    <style>
        #timeline {
   width: 800px;
   height: 210px;
   background-color:transparent;
   border: 0px none;
   margin-top: -50px;
   margin-left: -24px;
}
    </style>
    <script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
    </head>
<body>
    <iframe id="timeline" src="https://forecast.io/embed/#lat=33.38&lon=-86.70" scrolling="no" frameborder="0" ></iframe>
    <script type="text/javascript">
       
    </script>
</body>
</html>
modify the code above to suit your needs and save it as something like "forcast.html", then run webkit with some switches to manipulate the resultant image further:
Code: Select all
webkit2png -C --clipwidth=800 --clipheight=180 --scale=1 file:///Users/terry/Desktop/forecast.html --transparent --delay=2 -o forecast
Note: Help is available by running webkit2png -h and the --delay=2 lets the webpage render for 2 seconds before converting to a png.

The above produces the following image:
forecast-clipped.png
forecast-clipped.png (36.78 KiB) Viewed 3953 times


Terry

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 1:12 pm
by roussell
This should get you really close. You'll need to substitute your location; I got the link below by clicking on "Full Forecast" from the main WU website, then clicking on the "Forecast" tab on the next page. Modify and save the following code somewhere (I used the filename "wufc.html" in this example):

Code: Select all
<!DOCTYPE html>
<html>
<head>
    <style>
        #timeline {
   width: 800px;
   height: 1351px;
   background-color:transparent;
   border: 0px none;
   margin-top: -970px;
   margin-left: -10px;
}
    </style>
    <script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
    </head>
<body>
    <iframe id="timeline" src="https://www.wunderground.com/us/al/birmingham/zmw:35201.1.99999#div.plots.has-header" scrolling="no" frameborder="0" ></iframe>
    <script type="text/javascript">
       
    </script>
</body>
</html>


Then run webkit2png against it like so:
Code: Select all
webkit2png -C --clipwidth=800 --clipheight=400 --scale=1 file:///Users/terry/Desktop/wufc.html --transparent --delay=5 -o wu10day
to produce the following image:
wu10day-clipped.png
wu10day-clipped.png (104.88 KiB) Viewed 3938 times


I had to use a 5 second delay to allow WU to build the forecast. Also note that this will work until they change something on their site. How this gives you a good starting point.

Terry

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 3:47 pm
by norcoscia
Thanks Terry but...

Trying - webkit2png http://www.google.com/

got me...

2017-08-14 14:41:06.181 Python[95420:7212295] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
... something went wrong: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Easy for you is more than likely impossible for me :cry:

No worries - I already gave up - I don't what to mess up my Indigo PC - but thanks for trying to help me...

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 4:00 pm
by DaveL17
I have been using a combination of Indigo Control Pages and the Matplotlib Plugin to do this:

Screen Shot 2017-08-14 at 4.57.49 PM.png
Screen Shot 2017-08-14 at 4.57.49 PM.png (103.6 KiB) Viewed 3898 times

Re: CR or LF on a control page question

PostPosted: Mon Aug 14, 2017 4:45 pm
by roussell
norcoscia wrote:
Thanks Terry but...

Trying - webkit2png http://www.google.com/

got me...

2017-08-14 14:41:06.181 Python[95420:7212295] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file.
... something went wrong: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Easy for you is more than likely impossible for me :cry:

No worries - I already gave up - I don't what to mess up my Indigo PC - but thanks for trying to help me...


Don't give up, you're so close to a new addiction!! :twisted: The answer is in the error - use https://www.google.com for your test. (notice the "s" after http, that's a secure http request) so:
Code: Select all
webkit2png https://www.google.com/
will get you:
wwwgooglecom-full.png
wwwgooglecom-full.png (51.88 KiB) Viewed 3856 times



Terry