APNews

Post your work-in-progress and completed skins to share and discuss.
User avatar

APNews

October 6th, 2017, 1:15 am
jsmorley
Developer   [16339 posts]

APNews_2.0.rmskin
(841.45 KiB) Downloaded 23 times




Skin:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
MouseScrollDownAction=[!Refresh]

[Metadata]
Name=APNews
Author=Jeffrey Morley
Information=Description: | List of the 15 latest items from The Associated Press, with new items and items with key words in a different color. || Instructions: | See [Variables] section of skin to change settings. | Double-click header to change keyword(s). | Scroll down to refresh.
Version=Oct 5, 2017
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
FontFace=Fira Sans
FontSize=10
FontWeight=400
FontColor=255,255,255,255
SkinWidth=421
;How many minutes before an item is not "new"
NewMinutes=10
;Color for "new" items.
NewColor=207,250,213,255
;Color for items with key word(s).
KeyWordColor=181,233,255,255
;No need to change this manually. Double-click on the header to set.
Keywords=

[MeasureGMTOffset]
Measure=Plugin
Plugin=WebParser
Url=https://www.timeanddate.com/time/zone/usa/washington-dc
RegExp=(?siU)Current Offset: </span> <span class=big>UTC/GMT (.*) hours
UpdateRate=86400
StringIndex=1
FinishAction=[!CommandMeasure MeasureAPNews "Update"]

[MeasureAPNews]
Measure=Plugin
Plugin=WebParser.dll
Url=http://hosted.ap.org/dynamic/fronts/RAW?SITE=MYPSP&SECTION=HOME
RegExp=(?siU)^(.*)$
UpdateRate=120
ForceReload=1
FinishAction=[!UnpauseMeasure MeasureLuaScript][!UpdateMeasure MeasureLuaScript]
DecodeCharacterReference=1

[MeasureLuaScript]
Measure=Script
ScriptFile=APNews.lua
UpdateDivider=-1
Paused=1

[TextStyle]
W=(#SkinWidth# - 25)
H=15
X=9
Y=0R
FontFace=#FontFace#
FontSize=#FontSize#
FontColor=#FontColor#
FontWeight=#FontWeight#
SolidColor=0,0,0,1
Padding=5,3,5,3
StringAlign=Left
ClipString=1
AntiAlias=1
ToolTipType=1
ToolTipWidth=250

[MeterBackGround]
Meter=Shape
Shape=Rectangle 1,1,421,370 | StrokeWidth 2 | StrokeColor 110,110,110,255 | Fill Color 0,0,0,255

[MeterLogo]
Meter=Image
ImageName=#@#Images\APlogo.png
X=14
Y=8
H=30
PreserveAspectRatio=1
LeftMouseUpAction=["https://apnews.com/"]

[MeterHeader]
Meter=String
X=10R
Y=14
H=18
Text=ASSOCIATED PRESS HEADLINES
FontFace=#FontFace#
FontSize=#FontSize#
FontColor=#FontColor#
FontWeight=500
InlineSetting=GradientColor | 180 | 200,87,58,255 ; 0.0 | 240,240,240,255 ; 1.0
ToolTipTitle=Associated Press Headlines
ToolTipIcon=#@#Images\APLogo.ico
ToolTipText=Double-click to set keywords to watch.#CRLF#Current Keywords: #Keywords#
AntiAlias=1
MouseActionCursor=0
LeftMouseDoubleClickAction=[!CommandMeasure "MeasureInput" "ExecuteBatch 1-2"]

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=66
Y=14
H=18
W=(#SkinWidth# - 110)
SolidColor=0,0,0,255
FontFace=#FontFace#
FontColor=#FontColor#
FontSize=10
FocusDismiss=1
DefaultValue=#Keywords#
Command1=!WriteKeyValue Variables Keywords "$UserInput$" "#CURRENTPATH#APNews.ini"
Command2=!Refresh #CURRENTCONFIG#
DynamicVariables=1

[MeterTitle1]
Meter=String
MeterStyle=TextStyle
Y=13R
SolidColor=40,40,40,255

[MeterTitle2]
Meter=String
MeterStyle=TextStyle

[MeterTitle3]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255

[MeterTitle4]
Meter=String
MeterStyle=TextStyle

[MeterTitle5]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1

[MeterTitle6]
Meter=String
MeterStyle=TextStyle
UpdateDivider=-1

[MeterTitle7]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1

[MeterTitle8]
Meter=String
MeterStyle=TextStyle
UpdateDivider=-1

[MeterTitle9]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1

[MeterTitle10]
Meter=String
MeterStyle=TextStyle
UpdateDivider=-1

[MeterTitle11]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1

[MeterTitle12]
Meter=String
MeterStyle=TextStyle
UpdateDivider=-1

[MeterTitle13]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1

[MeterTitle14]
Meter=String
MeterStyle=TextStyle
UpdateDivider=-1

[MeterTitle15]
Meter=String
MeterStyle=TextStyle
SolidColor=40,40,40,255
UpdateDivider=-1


Lua:

Code: Select all

function Initialize()

   msWebParser = SKIN:GetMeasure('MeasureAPNews')
   msMeasureGMTOffset = SKIN:GetMeasure('MeasureGMTOffset')
   newColor = SKIN:GetVariable('NewColor')
   newMinutes = tonumber(SKIN:GetVariable('NewMinutes'))
   keywordColor = SKIN:GetVariable('KeywordColor')
   keywords = SKIN:GetVariable('Keywords')
   tKeywords = {}
   for keywords in string.gmatch(keywords, '[^ ]+') do table.insert(tKeywords, keywords) end
   
   patternItem = '<span class=\'apCaption\'><span class=\'apHeadline\'><span class=\'storylink\'><span class=\'latestnews\'><a href="(.-)</a></span></span></span></span><p class=\'ap%-adhocnewslisting%-p\' />'
   patternItemTitle = 'class=\'ap%-adhocnewslisting%-a\'>(.-)</a>'
   patternItemLink = '<a href="(.-)"'
   patternItemDate = 'CTIME=(.-)"'   

end

function Update()

   local entireSite = msWebParser:GetStringValue()
   
   BuildTables(entireSite)
   
   for i = 1, 15 do
      
      SKIN:Bang('!SetOption', 'MeterTitle'..i, 'Text', tTitles[i])
      SKIN:Bang('!SetOption', 'MeterTitle'..i, 'LeftMouseUpAction', '[http://hosted.ap.org'..tLinks[i]..']')
      SKIN:Bang('!SetOption', 'MeterTitle'..i, 'ToolTipText', tTitles[i])
      SKIN:Bang('!SetOption', 'MeterTitle'..i, 'FontColor', '')      
      
      local foundKeyword = 0
      for j = 1, #tKeywords do
         if string.find(string.upper(tTitles[i]), string.upper(tKeywords[j])) then foundKeyword = 1 end
      end
      if foundKeyword > 0 then
         SKIN:Bang('!SetOption', 'MeterTitle'..i, 'FontColor', keywordColor)
      end
      
      local timeNow = os.time(os.date('!*t'))
      local timeItem = TimeStamp(tDates[i])
      timeDiff = os.difftime(timeNow, timeItem) / 60
      if timeDiff < newMinutes then
         SKIN:Bang('!SetOption', 'MeterTitle'..i, 'FontColor', newColor)
      end
         SKIN:Bang('!SetOption', 'MeterTitle'..i, 'ToolTipText', tTitles[i]..'#CRLF##CRLF#'..Round(timeDiff)..' minutes ago.')

   end
   
   SKIN:Bang('!UpdateMeter', '*')
   SKIN:Bang('!Redraw')

end   

function BuildTables(inText)

   tLinks = {}
   tTitles = {}
   tDates = {}

   local init = 0
   
   for i = 1, 15 do
   
      itemStart, itemEnd = string.find(inText, patternItem, init)
      item = string.sub(inText, itemStart, itemEnd)
      tLinks[i] = string.match(item, patternItemLink)
      tTitles[i] = string.match(item, patternItemTitle)
      tDates[i] = string.match(item, patternItemDate)
      
      init = itemEnd + 1
   
   end
   
end

function TimeStamp(itemDate)
   
   --feed date format: 2017-01-17-11-38-43
   local year, month, day, hour, min, sec = string.match(itemDate, '^(.-)%-(.-)%-(.-)%-(.-)%-(.-)%-(.-)$')
   zone = tonumber(msMeasureGMTOffset:GetStringValue())
   
   return os.time({year=year, month=month, day=day, hour=(hour-zone), min=min, sec=sec, isdst=false})

end

Round = function(num, idp)
   
   assert(type(num) == 'number', 'Round expects a number.')   
   local mult = 10^(idp or 0)
   if num >= 0 then
      return math.floor(num * mult + 0.5) / mult
   else
      return math.ceil(num * mult - 0.5) / mult
   end
   
end

Return to “Share Your Creations”



Who is online

Users browsing this forum: No registered users and 5 guests