/feedtree.hws (c969195fafa9eec348ed15562720dc2c3a54e933) (5894 bytes) (mode 100755) (type blob)


Const #LIST_TREE = "feedtree"


Function p_FillListTree(listtree$, treetable)
	mui.Set(listtree$, "Quiet", True)
	;č ForEach začíná od 1 a teprve na konci se vrací k 0
	;ForEach(treetable, p_InsertNode, listtree$)

	For _i, t In IPairs(treetable)
    	mui.DoMethod(listtree$, "Insert",
			t.name, t.id, t.parent, "Tail", IIf(t.isNode, "List", ""))
		;č pro jednotlivé položky nelze zadat kontextové menu  
		;mui.Set(t.id, "ContextMenu", "channeltitlemenu")
    Next
	mui.Set(listtree$, "Quiet", False)
EndFunction


Function p_DumpFeedTree(listtree$)
	cFeeds = CreateList() ;currentFeeds
	p_DumpListTree(listtree$, cFeeds, "Root", "Root")
	Return(cFeeds)
EndFunction
        

;č tohle musí být rekurzivní 
Function p_DumpListTree(listtree$, tabletree, nodeid, muiid)
	Local isFound, t = mui.DoMethod(listtree$, "GetEntry", muiid, "Head", "")
	While isFound
		InsertItem(tabletree, {id=t.id, name=t.name, isNode=t.node, parent=nodeid})
		If t.Node = True Then p_DumpListTree(listtree$, tabletree, t.id, t.muiid)
		isFound, t = mui.DoMethod(listtree$, "GetEntry", t.muiid, "Next", "")
	Wend
EndFunction
        



Function p_FetchAll()
	p_Lock() 
	If IsOnline() Then  p_FetchGroup("Root")
	p_Unlock()
EndFunction

;č zjistit co je Node zač, 
;č podle toho postupovat
Function p_FetchCurrent()
	p_Lock() 
	Local isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", "Active", "Active", "")
	If isFound And Not PleaseStop And IsOnline()
		If t.Node 
			p_FetchGroup(t.muiid)
		Else
			If p_FetchFeed(t.id) = #ERR_NONE
				Ivor:Load(t.id) 
			EndIf 
		EndIf 
	EndIf 
	p_Unlock()
EndFunction


Function p_ShowCurrent()
	Local isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", "Active", "Active", "")
	If isFound And Not t.Node 
		Ivor:Load(t.id) 
	EndIf 
EndFunction

;č zjistit co je Node zač, 
;č podle toho postupovat
;č musí být rekurzivní
Function p_FetchGroup(muiid$)
	Local isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", muiid$, "Head", "")
	While isFound And Not PleaseStop
		If t.Node 
			p_FetchGroup(t.muiid)
		Else
			p_FetchFeed(t.id)
		EndIf 
		isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", t.muiid, "Next", "")
	Wend
EndFunction


;č stáhnout soubor, spočítat hešy, 
;č označit buď jako nové, nebo jako přečtené
;č smí se posílat JENOM fidy, nikoliv skupiny 
Function p_FetchFeed(feedid$)
	If HaveItem(feedsdata, feedid$)
		;č Pokud záznam existuje, MUSÍ mít MD5Sum a Name atributy 
		Local t = feedsdata[feedid$]
		If err_code = #ERR_NONE
			mui.DoMethod(#LIST_TREE, "Rename", feedid$, "\27".."5\27b" .. feedid$)
		Else
			mui.DoMethod(#LIST_TREE, "Rename", feedid$, "\27i" .. feedid$)
		EndIf 
	Else
		Local err_code = p_Download(feedid$, p_GetXMLname(feedid$))
		;č zde je to jednoduchý, stahování je bud úspěšné, nebo neúspěšné  
		mui.DoMethod(#LIST_TREE, "Rename", feedid$, 
					IIf(err_code = #ERR_NONE, "\27".."5\27b", "\27i") .. feedid$)
		
	EndIf 
	Return(err_code)
EndFunction


Function p_RemoveCurrent()
	Local isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", "Active", "Active", "")
	If isFound And mui.Request("Delete ".. IIf(t.Node, "group", "RSS feed"),
					"Do you realy want to delete ".. t.Name .. 
					IIf(t.Node, " \27ngroup and all its content?", "\27n?"), 
					"Yes|*Cancel", "Warning") 
		mui.DoMethod(#LIST_TREE, "Remove", "Active", t.id)
		;č vyhodit i přidružená data.   
		;č Hollywood se pak doopravdy se tváří, že tu položku nikdy neznal,
		;č HaveItem je vrací lež no a přístup pak způsobí chybu		
		feedsdata[t.id] = nil
		;č Na soubory ve složce Feeds sereme?
	EndIf 
EndFunction


Function p_CreateGroup()
	Local s$, ok = StringRequest("Create Group", "Enter new group name")
	
	If EmptyStr(s$) Then Return()
	s$ = StripStr(s$)
	If p_HasItem(s$, "Root")
		mui.Set("status", "Contents", "\27bGroup "..s$ .. " already exists")
	Else
		mui.DoMethod(#LIST_TREE, "Insert", "\27b"..s$, s$, "Root", 
					IIf(mui.Get(#LIST_TREE, "Active")="Off", "Tail","Active"),
					"List; Active")
		;p_Replay(err_code, "Group ".."\27b"..s$ .. " has been created") 
	EndIf
EndFunction



Function p_AddFeed()
	Local type, data$ = GetClipboard()
	Local s$, ok = StringRequest("Add RSS feed", "Enter feed adress", 
					IIf(type = #CLIPBOARD_TEXT And StartsWith(data$, "http"), 
															{Text=data$}, {}))
	If EmptyStr(s$) Then Return()
	s$ = StripStr(s$)
	;č zjednodušená kontrola, pokud řetězec obsahuje procenta,
	;č považujeme ho za "eskejpnutý".
	;č Na případ, kdy uživatel strčí do URLu osamělý znak procenta vysereme 
	/* houby, takhle hurl eskejpne úplně všechno
	If True ;FindStr(s$, "%") = -1
		easy = hurl.Easy()
		s$ = easy:Escape(s$) 
		easy:Close()
	EndIf */
	If p_HasItem(s$, "Root")
		mui.Set("status", "Contents", s$ .. " \27balready exists")
	Else
		mui.DoMethod(#LIST_TREE, "Insert", "\27".."5"..s$, s$, "Root", 
					IIf(mui.Get(#LIST_TREE, "Active")="Off", "Tail","Active"),
					"Active")
	EndIf
EndFunction


;č Kurňadrát, RapaGUI takové starosti nemá...
;č jen pro zábavu 
Function p_CanHas(nodeid$)
	Return(Not p_HasItem(nodeid$, "Root"))
EndFunction       

;č tohle musí být rekurzivní 
Function p_HasItem(nodeid$, muiid)
	Local isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", muiid, "Head", "")
	While isFound
		;InsertItem(tabletree, {id=t.id, name=t.name, isNode=t.node, parent=nodeid})
		If LowerStr(t.id) = LowerStr(nodeid$) Then Return(True)
		If t.Node And p_HasItem(nodeid$, t.muiid) Then Return(True)
		isFound, t = mui.DoMethod(#LIST_TREE, "GetEntry", t.muiid, "Next", "")
	Wend
	Return(False)
EndFunction



;bool = IsOnline()
;r$ = StripStr(s$)

; hURL is required
;e$ = easy:Escape(s$)


;name, isNode, id, parent
/*
Function p_InsertNode(i, t, listtree$)
	Local flags$ = IIf(t.isNode, "List", "")
	DebugPrint(i, t.id)
	mui.DoMethod(listtree$, "Insert", t.name, t.id, t.parent, "Tail", flags$)
EndFunction
*/

Mode Type Size Ref File
100755 blob 7473 1ab45355102d3c454b8d83e05e4af10b0447dee3 128px-Feed-icon.png
100755 blob 5463 ed01a493cc556c58582ab3cd0e0d7d7135542790 AppWindow.xml
100755 blob 3296 87f34b200c7e6abd9235c437a1927c745832e729 IvoR.hws
100755 blob 8666 15f9febc4613a032b73fbabec92bffe84216aea1 IvoRSS.hws
100755 blob 7191 6291191cf3b1e9b7dd44493a09e26918f2c6e3d1 IvoRSS.png
100755 blob 4405 6f1fc460afb31e6e38cd78dd01c0debaae6f5343 feeds.hws
100755 blob 5894 c969195fafa9eec348ed15562720dc2c3a54e933 feedtree.hws
100755 blob 4060 62e1a5849ef89d4c89eff1311f97a5110691f4e3 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