/IvoRSS.hws (5fb3546290c06f2b7077fbedb85cef583a60e574) (8539 bytes) (mode 100755) (type blob)

@VERSION 6,0
@APPTITLE "IvoRSS"
@APPVERSION "$VER: IvoRSS 0.2 (5.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"

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

PleaseStop = True






;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 0.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 "artt_copy":
			p_CopyContents("item_title", "Title")  
		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()
			
		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":
			If msg.TriggerValue >= 0
				Local chosen_item = items_list[msg.TriggerValue]
				mui.Set("item_title", "Contents", chosen_item.title)
				mui.Set("textfield", "Text", chosen_item.description)
			EndIf 
		Case "foundfeeds":
			lurk:AddFromlist("Active")
		EndSwitch
		
	
	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


/* 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() 
	; 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 5559 b4b21e48b891dd64eb9d1bc4a2897ce50bb139ac AppWindow.xml
100755 blob 3296 87f34b200c7e6abd9235c437a1927c745832e729 IvoR.hws
100755 blob 8539 5fb3546290c06f2b7077fbedb85cef583a60e574 IvoRSS.hws
100755 blob 7191 6291191cf3b1e9b7dd44493a09e26918f2c6e3d1 IvoRSS.png
100755 blob 4405 6f1fc460afb31e6e38cd78dd01c0debaae6f5343 feeds.hws
100755 blob 1694 83e47eb86860331dfe771f49029c00559a2f687e feedsdata.hws
100755 blob 8773 a1ac5af9c9ebafc5b2a012753079ee9602fbb98f feedtree.hws
100755 blob 6412 f39265cc944ed3be89260bc28f32c3805794fb0d lurk.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