/IvoR.hws (87f34b200c7e6abd9235c437a1927c745832e729) (3296 bytes) (mode 100755) (type blob)

; Module for the right side of the application

; Hollywood-like object programming...
IvoR = {}

;č Testy ukazují, že jediný způsob zavolat funkce je IvoR:Foo(),
;č zatímco k atributům lze přistupovat 
;č buď pomocí IvoR.Bar nebo self.Bar
;č V tom self nevidím žádný smysl

IvoR.parsers = CreateList()

Function IvoR:Load(feedid$)
	;DebugPrint(p_GetXMLname(feedid$)) 
	Local err_code, text$, _len = ?FileToString(p_GetXMLname(feedid$))
	; když máme chybu, tak rovnou končíme
	If err_code <>  #ERR_NONE
		mui.Set("status", "Contents", "\27b" .. GetErrorName(err_code))
		Return()
	EndIf 
	
	
	Ivor:Clear()
	
	; TODO: load icon
	
	local lastP = GetItem(IvoR.parsers, -1)
	If Not isNil(lastP) Then lastP:Stop()
	

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

	current_item = {title="", pubdate="", category="", description=""}
	
	Local p = XMLParser.New({StartElement = StartElement, EndElement=EndElement, CharacterData = CharacterData})
	InsertItem(Ivor.parsers, p) 
	DebugPrint("Created parser ", ListItems(Ivor.parsers)) 
	p:Parse(text$)
	;GetItem(Ivor.parsers, -1):Parse(text$)
	;p:Parse([[ text </to> ]])
	err_code = ?p:Close() 
	DebugPrint("Parser closed", ListItems(Ivor.parsers)) 
	RemoveItem(Ivor.parsers)
	;err_code = ?Ivor.parsers[0].Close() 
EndFunction 


Function IvoR:Clear()
	mui.Set("channel_title", "Contents", "")
	mui.Set("channel_title", "ContextMenu", "(none)")

	mui.Set("channel_description", "Contents", "")
	mui.Set("channel_description", "ContextMenu", "(none)")


	mui.Set("articles", "Quiet", True)
	For Local k = 1 To mui.Get("articles", "Entries")
		mui.DoMethod("articles", "Remove", "Last")
	Next
	mui.Set("articles", "Quiet", False)

	mui.Set("item_title", "Contents", "")
	mui.Set("item_title", "ContextMenu", "(none)")
	
	mui.Set("textfield", "Text", "")
	mui.Set("textfield", "ContextMenu", "(none)")
EndFunction 


Function StartElement(p, name$, attrs) 
	current_element$ = name$
	;DebugPrint("starts ", 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$) 
	;DebugPrint("ends ", 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)
		CheckEvents() 
		current_item = {title="", pubdate="", category="", description=""}
	EndIf
EndFunction 

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

 




Mode Type Size Ref File
100755 blob 7473 1ab45355102d3c454b8d83e05e4af10b0447dee3 128px-Feed-icon.png
100755 blob 4263 16222b3c614dbe238a1bc11e5777a856ab3a9bbc AppWindow.xml
100755 blob 3296 87f34b200c7e6abd9235c437a1927c745832e729 IvoR.hws
100755 blob 7832 0ea6e9a57b0722d1d1a999796e355c68c231e65e IvoRSS.hws
100755 blob 7191 6291191cf3b1e9b7dd44493a09e26918f2c6e3d1 IvoRSS.png
100755 blob 4405 6f1fc460afb31e6e38cd78dd01c0debaae6f5343 feeds.hws
100755 blob 5051 73109d160cdebe5caa01df0a2e9848b75a4c7066 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