It is currently April 18th, 2024, 9:45 pm

How to have quotes show up on specific dates from a spreadsheet or document

Get help with creating, editing & fixing problems with skins
AndyRainmeter
Posts: 3
Joined: October 12th, 2018, 9:53 pm

How to have quotes show up on specific dates from a spreadsheet or document

Post by AndyRainmeter »

So, as the title suggests, I'm looking to have a skin that puts a specific quotes up on specific dates, and I know this could be done with 366 IfCondition statements, but that would just turn into a tedious hassle, so I'm looking to have it pull the data from a spreadsheet or text document. I've seen from other posts that I've searched up that there is a quotes plugin, but that selects randomly, and I don't want it to be random. I've also seen that approaches with both WebParser and Lua are often used, and that Lua is probably better for this project, given the hardships with WebParser explained here. I also found the Lua date system here, but I am not sure as to how to integrate it into a Lua script like this one: (found under the first link)

Code: Select all

function Initialize()

   CURRENTPATH = SKIN:GetVariable('CURRENTPATH')
   Quotes = {}
   Authors = {}
   i = 0

   for line in io.lines(CURRENTPATH..'Listofquotes.txt') do
		if string.sub(line, 1, 7) == '<quote>' then
			i = i + 1
			Quotes[i] = string.sub(line, 8)
		elseif string.sub(line, 1, 8) == '<author>' then
			Authors[i] = string.sub(line, 9)
		else
			Quotes[i] = Quotes[i]..'#CRLF#'..line
		end
	end
   
end -->Initialize

function Update()

   rand = math.random(1, #Quotes)
   SKIN:Bang('!SetOption', 'MeterQuote', 'Text', Quotes[rand])
   SKIN:Bang('!SetOption', 'MeterAuthor', 'Text', Authors[rand])
   
   return 'Quote number: '..rand
   
end -->Update
So this is where I am at right now with this problem. Any help given is appreciated.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to have quotes show up on specific dates from a spreadsheet or document

Post by balala »

AndyRainmeter wrote: December 18th, 2018, 2:20 am So this is where I am at right now with this problem. Any help given is appreciated.
Let's start with the source files:
  • test.txt can be used however would be great if it's content could be modified to have closing tag after each statement. For example instead of <date>November 27, you should have to have <date>November 27</date>. Isn1t there a closing tag?
  • Test Rainmeter Quote Stuff.xls is very hard to be used (close to impossible), because there is no way to make a skin to natively read a .xls file.
So, most important question: are there closing tags in Test.txt, or can they be added?
AndyRainmeter
Posts: 3
Joined: October 12th, 2018, 9:53 pm

Re: How to have quotes show up on specific dates from a spreadsheet or document

Post by AndyRainmeter »

balala wrote: December 18th, 2018, 10:53 am Let's start with the source files:
  • test.txt can be used however would be great if it's content could be modified to have closing tag after each statement. For example instead of <date>November 27, you should have to have <date>November 27</date>. Isn1t there a closing tag?

    So, most important question: are there closing tags in Test.txt, or can they be added?
In the original post, the Text.txt does not have closing tags for <quote> and <author>, though I am not sure if <date> would have a closing tag.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to have quotes show up on specific dates from a spreadsheet or document

Post by balala »

AndyRainmeter wrote: December 18th, 2018, 8:14 pm In the original post, the Text.txt does not have closing tags for <quote> and <author>, though I am not sure if <date> would have a closing tag.
It would be much - much more easier to work with if there would be closing tags. Can they be added?
AndyRainmeter
Posts: 3
Joined: October 12th, 2018, 9:53 pm

Re: How to have quotes show up on specific dates from a spreadsheet or document

Post by AndyRainmeter »

balala wrote: December 18th, 2018, 8:49 pm It would be much - much more easier to work with if there would be closing tags. Can they be added?
Sure.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to have quotes show up on specific dates from a spreadsheet or document

Post by balala »

First here is a solution without having to modify the source (the test.txt file). Here is just one small problem: the skin doesn't show the Author for the last day in list (for exemple here for December 4th). It shows the Quote, but not the Author as well. For any other day it shows both, the Quote and the Author.
So, here is the code:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[Variables]
Current=0
Item=(?(?=.*\n)<date>(.*)\n<quote>(.*)\n<author>(.*))

[MeasureQuotes]
Measure=WebParser
UpdateRate=900
URL=file://#@#test.txt
RegExp=(?siU)<date>(.*)\n<quote>(.*)\n<author>(.*)#Item##Item##Item##Item##Item##Item##Item##Item##Item##Item#

[MeasureDate]
Measure=Time
Format=%B %#d

[MeasureQuote0]
Measure=String
String=Updating...

[MeasureAuthor0]
Measure=String
String=Updating...

[MeasureDate1]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=1
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "1"]

[MeasureQuote1]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=2

[MeasureAuthor1]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=3
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate2]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=4
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "2"]

[MeasureQuote2]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=5

[MeasureAuthor2]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=6
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate3]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=7
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "3"]

[MeasureQuote3]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=8

[MeasureAuthor3]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=9
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate4]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=10
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "4"]

[MeasureQuote4]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=11

[MeasureAuthor4]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=12
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate5]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=13
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "5"]

[MeasureQuote5]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=14

[MeasureAuthor5]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=15
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate6]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=16
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "6"]

[MeasureQuote6]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=17

[MeasureAuthor6]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=18
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate7]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=19
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "7"]

[MeasureQuote7]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=20

[MeasureAuthor7]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=21
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate8]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=22
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "8"]

[MeasureQuote8]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=23

[MeasureAuthor8]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=24
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate9]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=25
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "9"]

[MeasureQuote9]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=26

[MeasureAuthor9]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=27
RegExpSubstitute=1
Substitute="\n":""

[MeasureDate10]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=28
Substitute="<date>":""
IfMatch=[MeasureDate]
IfMatchAction=[!SetVariable Current "10"]

[MeasureQuote10]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=29

[MeasureAuthor10]
Measure=WebParser
Url=[MeasureQuotes]
StringIndex=30
RegExpSubstitute=1
Substitute="\n":""

[MeterQuoteAuthor]
Meter=STRING
MeasureName=MeasureQuote#Current#
MeasureName2=MeasureAuthor#Current#
X=0r
Y=10R
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=Quote of day: %1#CRLF#Author: %2
DynamicVariables=1
Take care to use the proper path of test.txt in the URL option of the [MeasureQuotes] measure.