Skip to content

Commit

Permalink
Merge branch 'Ferenc--language_pw'
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Cummer committed Jul 20, 2018
2 parents 9e06c2b + 52032f2 commit 28e1a0b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
5 changes: 5 additions & 0 deletions _site/content/posts/modules/prettyweather.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ None.
refreshInterval: 300
unit: "c"
view: 0
language: "en"
```
### Attributes
Expand Down Expand Up @@ -65,3 +66,7 @@ Values: `F` for Fahrenheit, `C` for Celcius.
`view` <br />
_Optional_ Wttr.in view configuration. <br />
Values: See `curl wttr.in/:help` for more details.

`language` <br />
_Optional_ Wttr.in language configuration. <br />
Values: See `curl wttr.in/:translation` for more details.
2 changes: 1 addition & 1 deletion docs/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ position Defines where in the grid this module&amp;rsquo;s widget will be displa
<description>Displays weather information as ASCII art from Wttr.in.
Source Code wtf/prettyweather/ Required ENV Variables None.
Keyboard Commands None.
Configuration prettyweather:enabled:truecity:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
Configuration prettyweather:enabled:truecity:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0language:&amp;#34;en&amp;#34; Attributes city Optional. It will grab the current location from your IP address if omitted.
Values: The name of any city supported by Wttr.in.
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
position Defines where in the grid this module&amp;rsquo;s widget will be displayed.</description>
Expand Down
2 changes: 1 addition & 1 deletion docs/posts/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ position Defines where in the grid this module&amp;rsquo;s widget will be displa
<description>Displays weather information as ASCII art from Wttr.in.
Source Code wtf/prettyweather/ Required ENV Variables None.
Keyboard Commands None.
Configuration prettyweather:enabled:truecity:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0 Attributes city Optional. It will grab the current location from your IP address if omitted.
Configuration prettyweather:enabled:truecity:&amp;#34;tehran&amp;#34;position:top:3left:5height:1width:1refreshInterval:300unit:&amp;#34;c&amp;#34;view:0language:&amp;#34;en&amp;#34; Attributes city Optional. It will grab the current location from your IP address if omitted.
Values: The name of any city supported by Wttr.in.
enabled Determines whether or not this module is executed and if its data displayed onscreen. Values: true, false.
position Defines where in the grid this module&amp;rsquo;s widget will be displayed.</description>
Expand Down
7 changes: 6 additions & 1 deletion docs/posts/modules/prettyweather/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ <h2 id="configuration">Configuration</h2>
</span><span class="w"> </span>width<span class="p">:</span><span class="w"> </span><span class="m">1</span><span class="w">
</span><span class="w"> </span>refreshInterval<span class="p">:</span><span class="w"> </span><span class="m">300</span><span class="w">
</span><span class="w"> </span>unit<span class="p">:</span><span class="w"> </span><span class="s2">&#34;c&#34;</span><span class="w">
</span><span class="w"> </span>view<span class="p">:</span><span class="w"> </span><span class="m">0</span></code></pre></div>
</span><span class="w"> </span>view<span class="p">:</span><span class="w"> </span><span class="m">0</span><span class="w">
</span><span class="w"> </span>language<span class="p">:</span><span class="w"> </span><span class="s2">&#34;en&#34;</span></code></pre></div>
<h3 id="attributes">Attributes</h3>

<p><code>city</code> <br />
Expand Down Expand Up @@ -190,6 +191,10 @@ <h3 id="attributes">Attributes</h3>
<em>Optional</em> Wttr.in view configuration. <br />
Values: See <code>curl wttr.in/:help</code> for more details.</p>

<p><code>language</code> <br />
<em>Optional</em> Wttr.in language configuration. <br />
Values: See <code>curl wttr.in/:translation</code> for more details.</p>

</div>

<div class="footer">
Expand Down
11 changes: 7 additions & 4 deletions weatherservices/prettyweather/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (

type Widget struct {
wtf.TextWidget
result string
unit string
city string
view string
result string
unit string
city string
view string
language string
}

func NewWidget() *Widget {
Expand All @@ -37,12 +38,14 @@ func (widget *Widget) prettyWeather() {
widget.unit = wtf.Config.UString("wtf.mods.prettyweather.unit", "m")
widget.city = wtf.Config.UString("wtf.mods.prettyweather.city", "")
widget.view = wtf.Config.UString("wtf.mods.prettyweather.view", "0")
widget.language = wtf.Config.UString("wtf.mods.prettyweather.language", "en")
req, err := http.NewRequest("GET", "https://wttr.in/"+widget.city+"?"+widget.view+"?"+widget.unit, nil)
if err != nil {
widget.result = err.Error()
return
}

req.Header.Set("Accept-Language", widget.language)
req.Header.Set("User-Agent", "curl")
response, err := client.Do(req)
if err != nil {
Expand Down

0 comments on commit 28e1a0b

Please sign in to comment.