It is currently March 19th, 2024, 2:32 am

Enigma Google Calendar Patch

A package of skins with a "theme" or by a single author
sbingha5
Posts: 2
Joined: February 4th, 2019, 1:38 pm

Re: Enigma Google Calendar Patch

Post by sbingha5 »

Thanks for the quick reply. That line of code just displayed "Za 3 dni". Some of it could be a language issue. Below is what I have as well as a screenshot of the result. I am not sure what I am missing to get the DTEND time to properly display. This is where my limits come in.

Code: Select all

	if Error then
		-- ERROR; QUEUE MESSAGES
		Queue['FeedTitle']   = Error.Title
		Queue['FeedLink']    = Error.Link
		Queue['Item1Title']  = Error.Description
		Queue['Item1Link']   = Error.Link
		Queue['Item1Desc']   = ''
		Queue['Item1End']    = ''
		Queue['Item1Date']   = ''
		Queue['Item1Unread'] = 0

		for i = 2, MinItems do
			Queue['Item'..i..'Title']   = ''
			Queue['Item'..i..'Link']    = ''
			Queue['Item'..i..'Desc']    = ''
			Queue['Item'..i..'End']    = ''
			Queue['Item'..i..'Date']    = ''
			Queue['Item'..i..'Unread']  = 0
		end
	else
		-- NO ERROR; QUEUE FEED
		Queue['FeedTitle'] = Feed.Title
		Queue['FeedLink']  = Feed.Link or ''

		for i = 1, math.max(#Feed, MinItems) do
			local Item = Feed[i] or {}			
			Queue['Item'..i..'Title']   = Item.Title  or ''
			Queue['Item'..i..'Link']    = Item.Link   or Feed.Link or ''
			Queue['Item'..i..'Desc']    = Item.Desc   or ''
			Queue['Item'..i..'Unread']  = Item.Unread or ''
			Queue['Item'..i..'End']     = Item.End and os.date(Timestamp, Item.End) or "
			Queue['Item'..i..'Date']    = Item.Date and os.date(Timestamp, Item.Date) or ''
			-- print(Item.Title..Item.Date)
		end
	end

	-- SET VARIABLES
	local VariablePrefix = SELF:GetOption('VariablePrefix', '')
	for k, v in pairs(Queue) do
		SKIN:Bang('!SetVariable', VariablePrefix..k, v)
	end
	
	-- FINISH ACTION   
	local FinishAction = SELF:GetOption('FinishAction', '')
	if FinishAction ~= '' then
		SKIN:Bang(FinishAction)
	end

	return Error and Error.Description or 'Finished #'..f..' ('..Feed.MeasureName..'). Name: '..Feed.Title..'. Type: '..Feed.Type..'. Items: '..#Feed..'.'
	
end

-----------------------------------------------------------------------
-- EXTERNAL COMMANDS

function Refresh(a)
	a = a and tonumber(a) or f
	if a == f then
		SKIN:Bang('!UpdateMeasure', SELF:GetName())
	else
		Input(a)
	end
end

function Show(a)
	f = tonumber(a)
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

function ShowNext()
	f = (f % #Feeds) + 1
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

function ShowPrevious()
	f = (f == 1) and #Feeds or (f - 1)
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

function MarkRead(a, b)
	b = b and tonumber(b) or f
	Feeds[b][a].Unread = 0
	UserInput = true
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

function MarkUnread(a, b)
	b = b and tonumber(b) or f
	Feeds[b][a].Unread = 1
	UserInput = true
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

function ToggleUnread(a, b)
	b = b and tonumber(b) or f
	Feeds[b][a].Unread = 1 - Feeds[b][a].Unread
	UserInput = true
	SKIN:Bang('!UpdateMeasure', SELF:GetName())
end

-----------------------------------------------------------------------
-- TYPES

function DefineTypes()
	Types = {
		RSS = {
			MatchLink     = '<link.->(.-)</link>',
			MatchItem     = '<item.-</item>',
			MatchItemID   = '<guid.->(.-)</guid>',
			MatchItemLink = '<link.->(.-)</link>',
			MatchItemDesc = '<description.->(.-)</description>',
			MatchItemEnd = '<pubDate.->(.-)</pubDate>',
			MatchItemDate = '<pubDate.->(.-)</pubDate>',
			MergeItems    = true,
			ParseDate     = function(s)
				local Date = {}
				local MatchTime = '%a%a%a, (%d%d) (%a%a%a) (%d%d%d%d) (%d%d)%:(%d%d)%:(%d%d) (.-)$'
				local MatchDate = '%a%a%a, (%d%d) (%a%a%a) (%d%d%d%d)$'
				if s:match(MatchTime) then
					Date.day, Date.month, Date.year, Date.hour, Date.min, Date.sec, Date.Offset = s:match(MatchTime)
				elseif s:match(MatchDate) then
					Date.day, Date.month, Date.year = s:match(MatchDate)
				end
				return (Date.year and Date.month and Date.day) and Date or nil
			end
			},
		Atom = {
			MatchLink     = '<link.-href=["\'](.-)["\']',
			MatchItem     = '<entry.-</entry>',
			MatchItemID   = '<id.->(.-)</id>',
			MatchItemLink = '<link.-href=["\'](.-)["\']',
			MatchItemDesc = '<summary.->(.-)</summary>',
			MatchItemEnd = '<modified.->(.-)</modified>',
			MatchItemDate = '<modified.->(.-)</modified>',
			MergeItems    = true,
			ParseDate     = function(s)
				local Date = {}
				local MatchTime = '(%d%d%d%d)%-(%d%d)%-(%d%d)T(%d%d)%:(%d%d)%:(%d%d)(.-)$'
				local MatchDate = '(%d%d%d%d)%-(%d%d)%-(%d%d)$'
				if s:match(MatchTime) then
					Date.year, Date.month, Date.day, Date.hour, Date.min, Date.sec, Date.Offset = s:match(MatchTime)
				elseif s:match(MatchDate) then
					Date.year, Date.month, Date.day = s:match(MatchDate)
				end
				return Date
			end
			},
		iCalendar = {
			MatchLink     = 'UID:(%S+)',
			MatchItem     = 'BEGIN:VEVENT.-END:VEVENT',
			MatchItemID   = 'UID:(%S+)',
			MatchItemLink = 'UID:(%S+)',
			MatchItemDesc = 'DESCRIPTION:(.-)\n',
			MatchItemEnd  = 'DTEND.-UID',
			MatchItemDate = 'DTSTART.-UID',
			MergeItems    = false,
			ParseDate     = function(s)
It should be 9:00 PM - 10:00 PM. I can fix the formatting to remove the date on my. I am not worried about displaying the date.
User avatar
pds
Posts: 79
Joined: April 12th, 2014, 12:52 pm
Location: Slovakia

Re: Enigma Google Calendar Patch

Post by pds »

I updated my solution :

Code: Select all

	
	
	-- NO ERROR; QUEUE FEED
		Queue['FeedTitle'] = Feed.Title
		Queue['FeedLink']  = Feed.Link or ''
        
		for i = 1, math.max(#Feed, MinItems) do
			local Item = Feed[i] or {}
		
		if Item.Date ~= nil then             						-add
		   today = os.date("%Y%m%d")
		   one = os.date("%Y%m%d",Item.Date)

	      rozdiel = os.difftime(one,today)

			         
	      if rozdiel == 0 then										--add
	        roz = 'Dnes'											--add  TODAY
  	  		 else
   	   	  if rozdiel == 1 then 
      		  roz = 'Zajtra'											--add TOMMORROW
         	  else
        	  		 if rozdiel < 5 then 
         	    roz = 'Za '..rozdiel..' dni'
            	 else roz = 'Za '..rozdiel..' dní'
         	  	 end
      	  	  end
   	    end
   	    else
   	    roz = ''
       end

			Queue['Item'..i..'Title']   = Item.Title  or ''
			Queue['Item'..i..'Link']    = Item.Link   or Feed.Link or ''
			Queue['Item'..i..'Desc']    = Item.Desc   or ''
			Queue['Item'..i..'Unread']  = Item.Unread or ''
         Queue['Item'..i..'Rem']     = roz  or ''														--add
			Queue['Item'..i..'Date']    = Item.Date and os.date(Timestamp, Item.Date) or ''
User avatar
krakoukas
Posts: 71
Joined: December 11th, 2018, 5:56 pm
Location: France
Contact:

Re: Enigma Google Calendar Patch

Post by krakoukas »

Works perfectly, thanks a lot for your work

Still a problem when an event duration is more than 1 day. It only shows the first day and then vanish the 2nd day

Image
jonnypickel
Posts: 4
Joined: July 18th, 2020, 4:50 pm

Re: Enigma Google Calendar Patch

Post by jonnypickel »

Hey, I'm noticing a bug with weekly repeating events. If I have an event that repeats every Monday, then I can see it on the calendar (when it's within the next 8 items) only on days that are not Monday. If today is the same day of the week as the repeating item then it will not show up, even when it has not occurred yet (i.e. it's noon right now and the event is scheduled at 3pm).

I feel like there needs to be another section in the Reader.lua file in DefineTypes() under the iCalendar section that handles weekly recurring events the way you have Monthly and Yearly represented, but my experience with lua is extremely limited.

Great work on this, by the way. Super useful!
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Enigma Google Calendar Patch

Post by CodeCode »

Hi eclectic-tech,

This is something that provides convenience.

How would I get my local holidays to show up on one of the 3 tabs?

Just not sure on where that ics address is....

Thanks.

EDIT: Found This: https://www.officeholidays.com/subscribe/australia/queensland
- Looks Promising as the rmskin registers the calendar, but so far I am not sure the ics format matches the lua config.

If I can suss it out I will report back here. :)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5364
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Enigma Google Calendar Patch

Post by eclectic-tech »

CodeCode wrote: September 23rd, 2020, 5:58 am Hi eclectic-tech,

This is something that provides convenience.

How would I get my local holidays to show up on one of the 3 tabs?

Just not sure on where that ics address is....

Thanks.

EDIT: Found This: https://www.officeholidays.com/subscribe/australia/queensland
- Looks Promising as the rmskin registers the calendar, but so far I am not sure the ics format matches the lua config.

If I can suss it out I will report back here. :)
Sorry for the late reply...

Google offers an Australia Holiday calendar, but the public URL link is designed to be 'embedded' in a webpage.

To have it work in GCal, add that holiday calendar to your list of calendars on Google, then go to the settings for that calendar and copy the 'Public URL'.
It will look something like this:
https://calendar.google.com/calendar/embed?src=en.australian%23holiday%40group.v.calendar.google.com&ctz=America%2FNew_York

For it to work in the skin the link needs to be modified, make these changes:
https://calendar.google.com/calendar/ical/en.australian%23holiday%40group.v.calendar.google.com/public/full.ics

Set that as the link for one of the variables in the skin;

Code: Select all

GoogleCalendar1=https://calendar.google.com/calendar/ical/en.australian%23holiday%40group.v.calendar.google.com/public/full.ics
Save and refresh. You should see the holidays in the skin.
ausholidays.png
Aside: I have not had time to look into modifying the lua code to correct missing features, so you may see things like 'Untitle' as the name for some feeds.
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Enigma Google Calendar Patch

Post by CodeCode »

Like I mentioned, I have this:
https://www.officeholidays.com/ics-clean/australia/queensland

However it is not showing through November like yours is.

I would like QLD only, so I will look for that and see if the changes apply the same way.

Ok Now I got his (I edited the 'Untitled' to day 'Holidays'. Now Its Holiday overload lol.
Calendar.gif.gif
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Enigma Google Calendar Patch

Post by CodeCode »

Oh, and thanks eclectic-tech, for finding this and showing me the fix.

Is there a list somewhere, that I can do this with a less overwhelming amount of every conceivable holiday - like just National, or Office holidays?

Ok, I changed the .../full.ics to .../basic.ics and it is much better.

It isnt better - it is exactly the same :)

How would this be modded to work - it is the public url for QLD holidays? :

https://calendar.google.com/calendar/embed?src=g6dfi5l91kv1e59694pbn15qva4ns2tp%40import.calendar.google.com&ctz=Australia%2FBrisbane
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5364
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA
Contact:

Re: Enigma Google Calendar Patch

Post by eclectic-tech »

CodeCode wrote: September 29th, 2020, 7:22 am Oh, and thanks eclectic-tech, for finding this and showing me the fix.

Is there a list somewhere, that I can do this with a less overwhelming amount of every conceivable holiday - like just National, or Office holidays?
The only ical list I have seen is on Google Calendar's 'Browse for other calendars'. If you find another source, the caveat is that most of them are HTML designed to be opened in a browser.
CodeCode wrote:How would this be modded to work - it is the public url for QLD holidays? :

https://calendar.google.com/calendar/embed?src=g6dfi5l91kv1e59694pbn15qva4ns2tp%40import.calendar.google.com&ctz=Australia%2FBrisbane
That link does not offer an ical format feed so it can not be adapted to work in this skin. The Google Australian holiday link I offered before did have an ical version.
User avatar
CodeCode
Posts: 1363
Joined: September 7th, 2020, 2:24 pm
Location: QLD, Australia

Re: Enigma Google Calendar Patch

Post by CodeCode »

eclectic-tech wrote: September 29th, 2020, 3:01 pm The only ical list I have seen is on Google Calendar's 'Browse for other calendars'. If you find another source, the caveat is that most of them are HTML designed to be opened in a browser.
That link does not offer an ical format feed so it can not be adapted to work in this skin. The Google Australian holiday link I offered before did have an ical version.
Fair enough. It works well enough, so I cant be too picky.

Thanks again.
Post Reply