willasm / vc-weather

MIT License
16 stars 0 forks source link

[Bug] Soemthing is wrong with the templates. #11

Open Drakemoor opened 1 day ago

Drakemoor commented 1 day ago

I'm sorry for the vague report, but I don't even know how to properly explain what exactly is wrong. So, I would give an example and hope it would make things clear.

I'm using Templater along with VC Weather plugins.

As a Templater template I have the following:

#### New Weather Plugin
##### Template 1

%weather1%  

##### Template 2

%weather2%

##### Template 3

%weather3%

##### Template 4

%weather4%  

##### Template 5

%weather5%

##### Template 6

%weather6% 

##### Template 7

%weather7%  

##### Template 8

%weather8%

Then as VC Weather templates I have:
Weather Template 1

Short one liner
%conditions% • Current Temp: %temp%° • Feels Like: %feelslike%°

Weather Template 2

More detailed
%address%: %dow2-now% %month4-now% %date1-now% - %hours12-now%:%mins-now% %ampm2-now%
Probability of precipitation: %precipprob% • (%preciptype%)
Current Temp: %temp%°C • Feels Like: %feelslike%°C
Wind: %windspeed-today% km/h from the %winddirstr-today% with gusts up to %windgust-today% km/h
Sunrise: %sunrise-today% • Sunset: %sunset-today%

Weather Template 3

Historical DIV
<img src=%iconurl% />&nbsp;%month4-now% %date1-now% %year1-now% • %hours12-now%:%mins-now% %ampm2-now% • %conditions%
&nbsp;Recorded Temp: %temp% • Felt like: %feelslike%
&nbsp;Wind: %windspeed-today% km/h from the %winddirstr-today% with gusts up to %windgust-today% km/h
&nbsp;Sunrise: %sunrise-today% • Sunset: %sunset-today%

Weather Template 4

Current DIV
<img src=%iconurl%  />&nbsp;%month4-now% %date1-now% %year1-now% • %hours12-now%:%mins-now% %ampm2-now% • %conditions%
&nbsp;Current Temp: %temp% • Feels like: %feelslike%
&nbsp;Wind: %windspeed-today% km/h from the %winddirstr-today% with gusts up to %windgust-today% km/h
&nbsp;Sunrise: %sunrise-today% • Sunset: %sunset-today%

Weather Template 5

M today's Weather
| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨Wind | 🌪Gusts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| %tempmax-today% | %tempmin-today%  | %icon-today% | %windspeed-today%<br>%winddirstr-today% | %windgust-today% | %humidity-today% | %pressure-today% | %iconurl% |

Weather Template 6

M Just prob table  
| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨Wind | 🌪Gusts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| %icon-today% | %preciptype-today%  | %precipprob-today% | 4 | 5 | 6 | 7 | 8 |

Weather Template 71

M just Icons  
%icon-today%  
%iconurl-today%

Weather Template 8

Today with next 3 days in a table  
|         |  Today<br>%month3-today% %date1-today%   |  %dow1-in1day%<br>%month3-in1day% %date1-in1day%  |  %dow1-in2days%<br>%month3-in2days% %date1-in2days%  |  %dow1-in3days%<br>%month3-in3days% %date1-in3days%  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **%tempmax-today%°C**          | **%tempmax-in1day%°C**          | **%tempmax-in2days%°C**          | **%tempmax-in3days%°C**          |
| Low     | **%tempmin-today%°C**          | **%tempmin-in1day%°C**          | **%tempmin-in2days%°C**          | **%tempmin-in3days%°C**          |
| Skies   | %conditions-today%             | %conditions-in1day% | %conditions-in2days%           | %conditions-in3days%           |
| PoP     | %precipprob-today%                | %precipprob-in1day%               | %precipprob-in2days%               | %precipprob-in2days%               |

When I create a new file using above setup, I get this:

#### New Weather Plugin
##### Template 1

Overcast • Current Temp: 10° • FSaint-Constant, Quebec: Tueday<img src="https://github.com/visualcrossing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Recorded Temp: 10 • Felt like: 10
&nbsp;Wind: 20 km/h from the Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:119 - 12:17 pm
Probability of precipitation: 0% • (none)
Current Temp: 10°C • Feels Like: 10°C
Wind: 20 km/h from the Southeast with gusts up to 37 km/h
Sunrise: 07:30:08 • Sunset: 17:45:11
 10°

##### Template 2

Saint-Constant, Quebec: Tueday<img src="https://github.com/visualcrossing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Recorded Temp: 10 • Felt like: 10
&nbsp;Wind: 20 km/h from the Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:119 - 12:17 pm
Probability of precipitation: 0% • (none)
Current Temp: 10°C • Feels Like: 10°C
Wind: 20 km/h from the Southeast with gusts up to 37 km/h
Sunrise: 07:30:08 • Sunset: 17:45:11

##### Template 3

<img src="https://github.com/visualcrossing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Recorded Temp: 10 • Felt like: 10
&nbsp;Wind: 20 km/h from the Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:11

##### Template 4

Overcast • Current Temp: 10° • FSaint-Constant, Quebec: Tueday<img src="https://github.com/v<img src="https://github.com/vis| 🌡Max℃ | 🌡Min℃ | ☔ Rain | �| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 |Gusts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| 12 | 1  | rain | 20<br>Southeast | 37 | 61% | 1027.9 | "https://github.com/visualcrossing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" |g/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true"  />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Current Temp: 10 • Feels like: 10
&nbsp;Wind: 20 km/h from the Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:11ing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Recorded Temp: 10 • Felt like: 10
&nbsp;Wind: 20 km/h from the Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:119 - 12:17 pm
Probability of precipitation: 0% • (none)
Current Temp: 10°C • Feels Like: 10°C
Wind: 20 km/h from the Southeast with gusts up to 37 km/h
Sunrise: 07:30:08 • Sunset: 17:45:11
 10°

##### Template 2

Saint-Constant, Quebec: Tueday<img src="https://github.com/v<img src="https://github.com/vis| 🌡Max℃ | 🌡Min℃ | ☔ Rain | �| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 |Gusts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| 12 | 1  | rain | 20<br>Southeast | 37 | 61% | 1027.9 | "https://github.com/visualcrossing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" |g/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true"  />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Current Temp: 10 • Feels like: 10
&nbsp;Wind: 20 km/h from the | 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 |with gusts up to 37 km/h
&n| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 |e: 07:30:08 • Sunset: 17:45:11ing/WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/cloudy.png?raw=true" />&nbsp;October 29 2024 • 12:17 pm • Overcast
&nbsp;Recorded Temp: 10 • Felt like: 10
&nbsp;Wind: 20 km/| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 | Southeast with gusts up to 37 km/h
&nbsp;Sunrise: 07:30:08 • Sunset: 17:45:119 - 12:17 pm
Probability of precipitation: 0% • (none)
Current Temp: 10°C • Feels Like: 10°C
Wind: 20 km/h from the Southeast with gusts up to 37 km/h
Sunrise: 07:30:08 • Sunset: 17:45:11

##### Template 6

| 🌡Max℃ | 🌡Min℃ | ☔ Rain | 💨rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"usts | 💧Humidity | 🌫Pressure | 🌳AQ |
| :-------: | :-------:  | :-------: | :-------: | :-------: | :-------: | :-------: | :-------: |
| rain | rain  | 100% | 4 | 5 | 6 | 7 | 8 | 

##### Template 7

rain  
"https://github.com/visua|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |
WeatherIcons/blob/main/PNG/1st%20Set%20-%20Color/rain.png?raw=true"  

##### Template 8

|         |  Today<br>Oct 29   |  Wed<br>Oct 30  |  Thu<br>Oct 31  |  Fri<br>Nov 1  |
| ------- | :---------------: | :---------------: | :---------------: | :---------------: |
| High    | **12°C**          | **20°C**          | **23°C**          | **19°C**          |
| Low     | **1°C**          | **10°C**          | **17°C**          | **5°C**          |
| Skies   | Snow, Rain, Partially cloudy             | Rain, Partially cloudy | Rain, Partially cloudy           | Rain, Partially cloudy           |
| PoP     | 100%                | 99%               | 94%               | 94%               |

Here is a screengrab from the Live Preview of the above:

https://github.com/user-attachments/assets/ec58ff57-3e94-4b1d-a181-370348caef3d

So, as you can see it's not only that the VC Weather's templates don't render properly, but there is something that completely breaks the output.

For example: The output shows the H5 headers properly until "Template 4" then it repeats the "Template 2" header.

Also, the 'Template 5' used to work flawlessly in 'OpenWeather' plugin. To use it with the new one I updated the variables, but as you can see the output is all messed up.

Let me know if I can provide anymore info to sort this out.

Thank you continuing to support this plugin. 🙇‍♂️

willasm commented 1 day ago

This is going to take a while to figure this out as I'm getting similar results? First thing I can see is that the icons are not set as inline images. Using template 5 as an example it should be...

M today's Weather 🌡Max℃ 🌡Min℃ ☔ Rain 💨Wind 🌪Gusts 💧Humidity 🌫Pressure 🌳AQ
%tempmax-today% %tempmin-today% %icon-today% %windspeed-today%
%winddirstr-today%
%windgust-today% %humidity-today% %pressure-today%

Note the

For some reason is the url in being put in quotes Remove the quotation marks and it displays properly.

Edit: I see what is wrong here. My plugin is putting the url in quotation marks (I need to change this to get the inline image to work correctly). You can get it to work though if you change it to <img src=%iconurl% /> and it will display correctly.

There is a lot going on here and I will need to go through each of your templates one by one to figure out what is happening here. I will post an update here after some more testing.

willasm commented 1 day ago

After a quick test I think I know what is happening here. I believe the next template is being inserted before the previous one has finished inserting itself. Try inserting this in a new note and it is easier to see.

#### New Weather Plugin
##### Template 1

%weather1%  

##### Template 2

%weather2%

Results in...

#### New Weather Plugin
##### Template 1

Partially cloudy • Current Temp:Edmonton: Tueday October 29 - 3:18 pm
Probability of precipitation: 0% • (none)
Current Temp: 5°C • Feels Like: 5°C
Wind: 13 km/h from the Southwest with gusts up to 18 km/h
Sunrise: 08:28:52 • Sunset: 18:05:37
s Like: 5°

##### Template 2

Edmonton: Tueday October 29 - 3:18 pm
Probability of precipitation: 0% • (none)
Current Temp: 5°C • Feels Like: 5°C
Wind: 13 km/h from the Southwest with gusts up to 18 km/h
Sunrise: 08:28:52 • Sunset: 18:05:37

You can see %weather1% starts inserting template 1 and template 2 is being appended to the partially inserted template 1 then %weather2%, the last template, is being inserted correctly. I never considered someone wanting to use more than one template in the same note and the way javascript works is it does not wait for a command to finish before it executes the next command. This results in the next template being inserted at the current cursor position which is where the previous template is currently being inserted. I know that sounds confusing, but basically I have to make sure the previous template insertion completes before doing the next template insertion. This will still require more testing to confirm that this is what is happening but I'm pretty sure this is what is happening.