It is currently August 4th, 2020, 5:41 am

Enigma Google Calendar Patch

Post your work-in-progress and completed skins to share and discuss.
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: 53
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: 73
Joined: December 11th, 2018, 5:56 pm
Location: France

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: 2
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!