/IvoRSS.hws (2952d46d403216b549fd61ef70e888b976bd7a08) (9254 bytes) (mode 100755) (type blob)

@VERSION 7,0
@APPTITLE "IvoRSS"
@APPVERSION "$VER: IvoRSS 1.1 (24.7.22)"
@APPCOPYRIGHT "© 2022, Aleksei Gerasimov"
@APPAUTHOR "Aleksei Gerasimov"
@APPDESCRIPTION "Simple RSS reader"
@APPIDENTIFIER "ivorss"
@REQUIRE "muiroyale", {Version=1, Revision=7}
@REQUIRE "hurl"
@REQUIRE "xmlparser" 
@DISPLAY {Hidden=True}

; There is some bug with Czech
;@CATALOG "IvoRSS", {Link=False}


@FILE 1, "AppWindow.xml"

; Generates default feeds 
; and puts to feeds.json
;@INCLUDE "feeds.hws" 

@INCLUDE "feedsdata.hws"
@INCLUDE "feedtree.hws"
@INCLUDE "lurk.hws"
@INCLUDE "IvoR.hws"
@INCLUDE "textfield.hws"

@BRUSH 1, "128px-Feed-icon.png", {LoadAlpha=True, ScaleHeight=32, ScaleWidth=32}
ChannelIconBrush = 1

PleaseStop = True
AllowImages = True ; Later will be set up in p_StartUpLoading() 
UseDefaultDownloader = False ; Later will be set up in p_StartUpLoading() 







;Width=#KEEPASPRAT
/*
** Handles all incoming events

Action:   Initialized to "MUIRoyale".

    Class:    Contains the name of the MUI class this event comes from, e.g.
              "Cycle".

    Attribute:
              Contains the name of the class attribute that has triggered the
              event, e.g. "Active".

    ID:       Contains the ID of the MUI object that triggered this event, e.g.
              "mycycle".

    TriggerValue:
              Contains the current value of the attribute that triggered this
              event. You could also find this out by doing a mui.Get() on the
              object but it is more convenient to get the current value directly
              to your event callback.

    MUIUserData:
              If the object was assigned certain userdata, it will be passed to
              the event handler callback in this tag. See Notify.UserData for
              details.

    NotifyData:
              If the object was assigned certain notify data, it will be passed
              to the event handler callback in this tag. See Notify.NotifyData
              for details.
*/
Function p_MUIEvent(msg)
    DebugPrint(msg.Action, " event!", 
				  "  Class:", msg.Class, 
				  "  Attribute:", msg.Attribute,
				  "  ID:", msg.ID, 
				  "  TriggerValue:", msg.TriggerValue)
				  ;"  MUIUserData:", IIf(HaveItem(msg, "MUIUserData"), msg.MUIUserData, ""),
				  ;"  NotifyData:", msg.NotifyData)
    Switch msg.Class
    Case "Window":
        Switch msg.Attribute
        Case "CloseRequest":
			Switch msg.ID
			Case "win":
				p_SaveSettings() 
				End
			Case "metawin":
				mui.Set("metawin", "open", False)
			EndSwitch
        EndSwitch
    Case "Menuitem":
        Switch msg.ID
        Case "menu_about":
            Local reqtext$ = "\27c\27b IvoRSS 1.1 \n\27n Simple RSS client"
            If mui.Request("About", reqtext$, "Open repository|*OK") Then OpenURL("http://rocketgit.com/iam-git/IvoRSS")
        Case "menu_about_mui":
            mui.DoMethod("app", "AboutMUI")
        Case "menu_about_muiroyale":
            mui.DoMethod("app", "AboutMUIRoyale")
        Case "menu_quit":
			p_SaveSettings() 
            End
        Case "menu_muisettings":
            mui.DoMethod("app", "OpenConfigWindow")
		Case "rssi_copy":
			p_CopyIcon() 
		Case "rsst_copy":
			p_CopyContents("channel_title", "Channel title")  
		Case "rssd_copy":
			p_CopyContents("channel_description", "Channel description") 
		Case "rsst_copyurl":
			p_CopyContents("channel_link", "Channel link") 
		
		Case "artt_copyauthor":
			p_CopyContents("item_author", "E-mail")  
		Case "artt_copytitle":
			p_CopyContents("item_title", "Title") 
		Case "artt_copyurl":
			p_CopyContents("item_link", "URL") 
		Case "art_copy":
			p_CopyText()
			
		Case "menu_save":
			FallThrough
		Case "fdtm_save":
			p_SaveSettings()
			
		Case "menu_lurk":
			FallThrough
		Case "fdtm_lurk":
			mui.Set("metawin", "open", True)
		
		Case "menu_addgroup":
			FallThrough
		Case "fdtm_addgroup":			
			p_CreateGroup()
			
		Case "menu_add":
			FallThrough
		Case "fdtm_add":		
			p_AddFeedRequest()
			
		Case "menu_hide":
			FallThrough
		Case "fdtm_hide":
			p_HideFeeds()
			
		Case "menu_expand":
			FallThrough
		Case "fdtm_expand":
			p_ExpandFeeds()
			
		Case "menu_fetchall":
			FallThrough
		Case "fdtm_fetchall":
            p_FetchAll()
			
		Case "fdtm_fetch":
			p_FetchCurrent()
		
		Case "fdtm_remove":
			p_RemoveCurrent()			
			
		Case "fdtm_copyurl":
			p_CopyTreeURL()
			
		Case "artl_showsource":
			p_ShowSource()
			
			
		EndSwitch
	Case "Listtree":
		Switch msg.Attribute
		Case "DoubleClick":
			;č Skupiny nemůžou získat dvojitý klik, jen se otevřou-zavřou
			;č takže jdeme rovnou stahovat
            p_FetchCurrent()
        Case "Active":
            p_ShowCurrent()
        EndSwitch
		
		
	Case "Listview":
		Switch msg.ID
		Case "articles":
			IvoR:ShowArticle(msg.TriggerValue)
		Case "foundfeeds":
			lurk:AddFromlist("Active")
		EndSwitch
		
	Case "Text":
		If msg.TriggerValue = 0 Then IvoR:OpenLink(msg.ID)
	
	Case "Button":
		Switch msg.ID
		Case "reqclosebtn":
			mui.Set("metawin", "open", False)
		Case "reqaddbtn":
			lurk:AddSelected()
			
		Case "lurkbtn":
			mui.Set("metawin", "open", True)
		Case "addbtn":
            p_AddFeedRequest()
        Case "fetchbtn":
            p_FetchCurrent()
		Case "fetchallbtn":
            p_FetchAll()
		Case "stopbtn":
            p_Unlock()
			
		Case "herewegobtn":
            p_StartLurk()
		Case "stoplurkbtn":
            lurk.PleaseStop = True
			
			
			
		EndSwitch
    EndSwitch
EndFunction





;č že FFS prý podporovala  
;č jména souborů jen do 31 znaků
Function p_GetFileID(feedid$)
	Return(LeftStr(MD5Str(feedid$), 26))
EndFunction

Function p_GetXMLname(feedid$)
	Return("Feeds/"..p_GetFileID(feedid$)..".xml")
EndFunction

Function p_GetLogoName(feedid$, extension$)
	Return("Feeds/"..p_GetFileID(feedid$).."." .. extension$)
EndFunction


/* From Hollywood docs:
Action:   #DOWNLOADFILE_STATUS
Count:    Contains the number of bytes that have already been                  downloaded.
Total:    Contains the size of the file being downloaded.
UserData: Contains the value you passed in the "userdata" argument.

The callback function of type #DOWNLOADFILE_STATUS should normally return FALSE. If it returns TRUE, the download operation will be aborted.*/
Function p_callback(t)
	If t.Action = #DOWNLOADFILE_STATUS
		mui.Set("status", "Contents", 
			"Downloading (" .. t.Count .. "/" .. t.Total .. ") " .. t.UserData
				)
		CheckEvents() ; keep MUI responsive
		Return(PleaseStop)
	EndIf
EndFunction


;č stáhnout soubor
Function p_Download(url$, filename$)
	Local err_code, _empty_str$, count = ?DownloadFile(url$, 
			{File=filename$, Adapter = "hurl", Fail404=True, Encoded=True},
			p_callback, url$)
	p_Replay(err_code, count .. "bytes from " .. url$ .. " transmitted") 
	CheckEvents() ; keep MUI even more responsive
	Return(err_code)
EndFunction




/*
Function p_Replay(err_code, msg$) 
	If err_code = #ERR_NONE
		mui.Set("status", "Contents", msg$)
	Else
		mui.Set("status", "Contents", "\27b" .. GetErrorName(err_code))
	EndIf 
EndFunction 
*/

Function p_Replay(err_code, msg$) 
	mui.Set("status", "Contents", 
			IIf(err_code = #ERR_NONE, msg$, "\27b" .. GetErrorName(err_code)))
EndFunction 


Function p_CopyIcon() 
	err_code = ?SetClipboard(#CLIPBOARD_IMAGE, ChannelIconBrush)
	p_Replay(err_code, "Icon is copied") 
EndFunction 

Function p_CopyContents(source_id$, source_desc$) 
	err_code = ?SetClipboard(#CLIPBOARD_TEXT, mui.Get(source_id$, "Contents"))
	p_Replay(err_code, source_desc$ .. " is copied") 
EndFunction 

Function p_CopyText() 
	err_code = ?SetClipboard(#CLIPBOARD_TEXT, mui.Get("textfield", "Text"))
	p_Replay(err_code, "Text is copied") 
EndFunction 







Function p_StartUpLoading() 
	Local t, n, console = GetCommandLine()
	For i, v In IPairs(t) ;č tam jsou pouze číselné indexy. Možno. 
		Switch UpperStr(v["arg"])
		Case "DONOTLOADIMAGES":
			AllowImages = False
		Case "USEDEFAULTDOWNLOADER":
			UseDefaultDownloader = True
		EndSwitch
	Next 
	; default feeds are generated by feeds.hws
	Local err_code, s$, _len = ?FileToString("feeds.json")
	p_Replay(err_code, "Program started") 

	err_code = ?p_FillListTree("feedtree", DeserializeTable(s$))
	p_Replay(err_code, "Feeds are imported") 

	;feedsdata = {} ; Global
	err_code = ?LoadPrefs(feedsdata)
	p_Replay(err_code, "Settings loaded") 
EndFunction 


Function p_SaveSettings() 
	p_SaveFeeds()
	
	Local err_code = ?SavePrefs(feedsdata)
	p_Replay(err_code, "State saved") 
EndFunction 

Function p_Lock() 
	mui.Set("fetchbtn", "Disabled", True)
	mui.Set("fetchallbtn", "Disabled", True)
	mui.Set("stopbtn", "Disabled", False)
	PleaseStop = False
EndFunction 

Function p_Unlock()
	PleaseStop = True
	mui.Set("stopbtn", "Disabled", True)
	mui.Set("fetchbtn", "Disabled", False)
	mui.Set("fetchallbtn", "Disabled", False)
EndFunction 


Function p_StartLurk() 
	mui.Set("herewegobtn", "Disabled", True)
	mui.Set("stoplurkbtn", "Disabled", False)
	lurk.PleaseStop = False

	lurk:Explore(mui.Get("websource", "Contents"))

	mui.Set("stoplurkbtn", "Disabled", True)
	mui.Set("herewegobtn", "Disabled", False)
EndFunction 



mui.CreateGUI(ReadString(1))
InstallEventHandler({MUIRoyale = p_MUIEvent})

p_StartUpLoading()

Repeat
	WaitEvent
Forever

Mode Type Size Ref File
100755 blob 7473 1ab45355102d3c454b8d83e05e4af10b0447dee3 128px-Feed-icon.png
100755 blob 6349 eeaf40384a6978792850e51646c94025c31c9263 AppWindow.xml
100755 blob 8882 af0ada41f32b55988a04e827ef3cabfe15e898bc IvoR.hws
100755 blob 9254 2952d46d403216b549fd61ef70e888b976bd7a08 IvoRSS.hws
100755 blob 7191 6291191cf3b1e9b7dd44493a09e26918f2c6e3d1 IvoRSS.png
100755 blob 1093 263306d87c51114b1320be2ee3277ea0bff99b1f LICENSE
100755 blob 1906 4e18f3e83d428c9bf940ef131f8b2187d2c2bbd3 ReadMe
100755 blob 4007 8956c1bb5d76b481d4e2458b16a64fbee8f6f9e6 feeds.hws
100755 blob 1694 83e47eb86860331dfe771f49029c00559a2f687e feedsdata.hws
100755 blob 13089 b20da94931f651264cb9ab0655fca95b0ac1a3f3 feedtree.hws
100755 blob 7305 d6eda6d26dcd117cbe3eeda270397ef72a592f83 lurk.hws
100755 blob 10842 5b70109781bedd7885042d29046cbd23f86e5672 textfield.hws
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/iam-git/IvoRSS

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/iam-git/IvoRSS

Clone this repository using git:
git clone git://git.rocketgit.com/user/iam-git/IvoRSS

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main