/IvoRSS.hws (36ee3e1659b48fc561c56ce05e578cd5b8a9dd3d) (5570 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}

@FILE 1, "AppWindow.xml"

@INCLUDE "feedtree.hws"

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

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

Function p_MUIEvent(msg)
    DebugPrint("MUI event!", "  Class:", msg.Class, "  ID:", msg.ID, "  Attribute:", msg.Attribute)
    Switch msg.Class
    Case "Window":
        Switch msg.Attribute
        Case "CloseRequest":
            End
        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":
            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_SaveFeeds()
			
		Case "menu_hide":
			FallThrough
		Case "fdtm_hide":
			p_HideFeeds()
			
		Case "menu_expand":
			FallThrough
		Case "fdtm_expand":
			p_ExpandFeeds()
			
			
		EndSwitch
	Case "Listview":
		;assert(msg.Attribute = "Active")
		;assert(msg.ID = "articles")
		Local chosen_item = items_list[msg.TriggerValue]
		mui.Set("item_title", "Contents", chosen_item.title)
		mui.Set("textfield", "Text", chosen_item.description)
        ;Switch msg.ID
        ;Case "CloseRequest":
        ;    End
        ;EndSwitch
    EndSwitch
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 

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


Function p_SaveFeeds() 
	cFeeds = p_DumpFeedTree("feedtree")
	prf = {feeds=cFeeds, feedsdata={}}
	err_code = ?SavePrefs(prf)
	p_Replay(err_code, "Tree arrangement saved") 
EndFunction 

	
Function p_HideFeeds() 
	mui.DoMethod("feedtree", "close", "root", "all")
EndFunction 

Function p_ExpandFeeds() 
	mui.DoMethod("feedtree", "open", "root", "all")
EndFunction 

url$ = "https://www.powerpc-notebook.org/en/feed/"

DownloadFile(url$, {File = "feed.xml", Adapter = "hurl"})

text$ = FileToString("feed.xml")
;mui.Set("textfield", "Text", text$)


items_list = CreateList()
channel_level = True
current_element$ = Nil

current_item = {title="", pubdate="", category="", description=""}
 
Function StartElement(p, name$, attrs) 
	current_element$ = name$
	
	If name$ = "item" Then channel_level = False
	
	
	
	For i,v In Pairs(attrs) 
		If GetType(i) = #STRING Then DebugPrint("-->", i .. "=" .. v) 
	Next 
 
EndFunction 
 
Function EndElement(p, name$) 
	current_element$ = nil
	If name$ = "item"
		mui.DoMethod("articles", "Insert", "Bottom", 
					current_item.title,
					current_item.pubdate,
					current_item.category)
		InsertItem(items_list, current_item)
		current_item = {title="", pubdate="", category="", description=""}
	EndIf
EndFunction 


Function CharacterData(p, str$) 
	If channel_level
		If current_element$ = "title" Then mui.Set("channel_title", "Contents", str$)
		If current_element$ = "description" Then mui.Set("channel_description", "Contents", str$)
	
	else
		If current_element$ = "title" Then current_item.title = str$
		If current_element$ = "pubDate" Then current_item.pubdate = str$
		If current_element$ = "description" Then current_item.description = str$
		If current_element$ = "category"
			If current_item.category = ""
				current_item.category = str$
			Else
				current_item.category = current_item.category .. ", " .. str$
			EndIf 
		Endif
	EndIf
EndFunction 

 
p = XMLParser.New({StartElement = StartElement, EndElement=EndElement, CharacterData = CharacterData}) 
p:Parse(text$)
p:Close() 



; dFeeds is imported from feedtree.hws
prf = {feeds=dFeeds, feedsdata={}}
err_code = ?LoadPrefs(prf)
p_Replay(err_code, "Program started") 

err_code = ?p_FillListTree("feedtree", prf.feeds)
p_Replay(err_code, "Settings loaded") 
		



;sum$ = MD5Str(s$)

;OpenURL(url$)

;t = CreateList()







;Print(GetCatalogString(4, "default string"))

Repeat
	WaitEvent
Forever

Mode Type Size Ref File
100755 blob 7473 1ab45355102d3c454b8d83e05e4af10b0447dee3 128px-Feed-icon.png
100755 blob 4158 59f26e4203c6350507fa9262d4aa9ad9c1ac016b AppWindow.xml
100755 blob 5570 36ee3e1659b48fc561c56ce05e578cd5b8a9dd3d IvoRSS.hws
100755 blob 619 8b7ccc28d9a68590d798197957c23d1809c7f400 feeds.hws
100755 blob 2674 e11c68227d7c7a277fa08a96955e79162e9c8934 feedtree.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