File IvoR.hws changed (mode: 100755) (index d380be7..3cf6263) |
... |
... |
IvoR.parsers = CreateList() |
8 |
8 |
|
|
9 |
9 |
|
|
10 |
10 |
Function IvoR:Load(feedid$) |
Function IvoR:Load(feedid$) |
11 |
|
;DebugPrint(p_GetXMLname(feedid$)) |
|
12 |
11 |
Local err_code, xml$, _len = ?FileToString(p_GetXMLname(feedid$)) |
Local err_code, xml$, _len = ?FileToString(p_GetXMLname(feedid$)) |
13 |
12 |
; když máme chybu, tak rovnou končíme |
; když máme chybu, tak rovnou končíme |
14 |
13 |
If err_code <> #ERR_NONE |
If err_code <> #ERR_NONE |
|
... |
... |
Function IvoR:Load(feedid$) |
16 |
15 |
Return() |
Return() |
17 |
16 |
EndIf |
EndIf |
18 |
17 |
|
|
|
18 |
|
;č dále je třeba pozastavit případný parser "z minula" |
|
19 |
|
local lastP = GetItem(IvoR.parsers, -1) |
|
20 |
|
If Not isNil(lastP) Then lastP:Stop() |
19 |
21 |
|
|
|
22 |
|
;č teprve teď uklízíme |
20 |
23 |
Ivor:Clear() |
Ivor:Clear() |
21 |
24 |
|
|
22 |
25 |
; TODO: load icon |
; TODO: load icon |
23 |
26 |
|
|
24 |
|
local lastP = GetItem(IvoR.parsers, -1) |
|
25 |
|
If Not isNil(lastP) Then lastP:Stop() |
|
26 |
27 |
|
|
27 |
|
|
|
|
28 |
|
;č a vytahujeme seznam přečteného |
|
29 |
|
Local t = fd_Get(feedid$, "guids") |
|
30 |
|
If GetType(t) = #TABLE |
|
31 |
|
self.oldguids = t |
|
32 |
|
Else |
|
33 |
|
self.oldguids = {} |
|
34 |
|
EndIf |
|
35 |
|
|
|
36 |
|
;č na konci tohle nahradí už "staré" guids |
|
37 |
|
;č Je to aby se staré, nejspíš i nedostupné zápisy nehromadily. |
|
38 |
|
;č Funkce "pravé" strany budou rovnou psát do IvoR.guids |
|
39 |
|
self.guids = {} |
|
40 |
|
|
28 |
41 |
|
|
29 |
42 |
|
|
30 |
43 |
Local p = XMLParser.New({StartElement = StartElement, EndElement=EndElement, CharacterData = CharacterData}) |
Local p = XMLParser.New({StartElement = StartElement, EndElement=EndElement, CharacterData = CharacterData}) |
|
... |
... |
Function IvoR:Load(feedid$) |
47 |
60 |
;č moc se mně neptejte, ale zdá se, |
;č moc se mně neptejte, ale zdá se, |
48 |
61 |
;č že se vracejí odlišné chyby se stejným kódem |
;č že se vracejí odlišné chyby se stejným kódem |
49 |
62 |
If errorname = "Error closing parser: unknown encoding!" |
If errorname = "Error closing parser: unknown encoding!" |
50 |
|
DebugPrint("Eště jeden pokus...") |
|
51 |
63 |
|
|
52 |
64 |
Ivor:Clear() |
Ivor:Clear() |
53 |
65 |
|
|
|
... |
... |
Function IvoR:Load(feedid$) |
78 |
90 |
DebugPrint("Parser closed", ListItems(Ivor.parsers)) |
DebugPrint("Parser closed", ListItems(Ivor.parsers)) |
79 |
91 |
RemoveItem(Ivor.parsers) |
RemoveItem(Ivor.parsers) |
80 |
92 |
EndIf |
EndIf |
|
93 |
|
|
|
94 |
|
fd_Set(feedid$, "guids", self.guids) |
|
95 |
|
|
81 |
96 |
EndFunction |
EndFunction |
82 |
97 |
|
|
83 |
98 |
|
|
|
99 |
|
Function IvoR:ShowArticle(pos) |
|
100 |
|
If pos >= 0 |
|
101 |
|
Local chosen_item = self.items_list[pos] |
|
102 |
|
mui.Set("item_title", "Contents", tf_Label(chosen_item.title)) |
|
103 |
|
mui.Set("textfield", "Text", tf_TextField(chosen_item.description)) |
|
104 |
|
|
|
105 |
|
If Not HaveItem(self.guids, chosen_item.guid) |
|
106 |
|
mui.DoMethod("articles", "Rename", pos, |
|
107 |
|
chosen_item.title, |
|
108 |
|
chosen_item.pubdate, |
|
109 |
|
chosen_item.category) |
|
110 |
|
self.guids[chosen_item.guid] = 1 |
|
111 |
|
EndIf |
|
112 |
|
EndIf |
|
113 |
|
EndFunction |
|
114 |
|
|
84 |
115 |
Function IvoR:Clear() |
Function IvoR:Clear() |
85 |
116 |
mui.Set("channel_title", "Contents", "") |
mui.Set("channel_title", "Contents", "") |
86 |
117 |
;mui.Set("channel_title", "ContextMenu", "(none)") |
;mui.Set("channel_title", "ContextMenu", "(none)") |
|
... |
... |
Function IvoR:Clear() |
99 |
130 |
|
|
100 |
131 |
|
|
101 |
132 |
|
|
102 |
|
items_list = CreateList() ;č ten necháme globálním |
|
|
133 |
|
self.items_list = CreateList() |
103 |
134 |
channel_level = True |
channel_level = True |
104 |
135 |
current_element$ = Nil |
current_element$ = Nil |
105 |
136 |
|
|
106 |
|
current_item = {title="", pubdate="", category="", description=""} |
|
|
137 |
|
current_item = {title="", pubdate="", category="", description="", guid=""} |
107 |
138 |
EndFunction |
EndFunction |
108 |
139 |
|
|
109 |
140 |
|
|
|
... |
... |
Function EndElement(p, name$) |
125 |
156 |
;DebugPrint("ends ", name$) |
;DebugPrint("ends ", name$) |
126 |
157 |
current_element$ = nil |
current_element$ = nil |
127 |
158 |
If name$ = "item" |
If name$ = "item" |
|
159 |
|
Local preparse = "" |
|
160 |
|
If HaveItem(IvoR.oldguids, current_item.guid) |
|
161 |
|
IvoR.guids[current_item.guid] = 1 |
|
162 |
|
preparse = "" |
|
163 |
|
Else |
|
164 |
|
preparse = "\27b" |
|
165 |
|
EndIf |
128 |
166 |
mui.DoMethod("articles", "Insert", "Bottom", |
mui.DoMethod("articles", "Insert", "Bottom", |
129 |
|
current_item.title, |
|
130 |
|
current_item.pubdate, |
|
131 |
|
current_item.category) |
|
132 |
|
InsertItem(items_list, current_item) |
|
|
167 |
|
preparse .. current_item.title, |
|
168 |
|
preparse .. current_item.pubdate, |
|
169 |
|
preparse .. current_item.category) |
|
170 |
|
InsertItem(IvoR.items_list, current_item) |
133 |
171 |
CheckEvents() |
CheckEvents() |
134 |
|
current_item = {title="", pubdate="", category="", description=""} |
|
|
172 |
|
current_item = {title="", pubdate="", category="", description="", guid=""} |
135 |
173 |
EndIf |
EndIf |
136 |
174 |
EndFunction |
EndFunction |
137 |
175 |
|
|
|
... |
... |
Function CharacterData(p, str$) |
143 |
181 |
If current_element$ = "title" Then mui.Set("channel_title", "Contents", tf_Label(str$)) |
If current_element$ = "title" Then mui.Set("channel_title", "Contents", tf_Label(str$)) |
144 |
182 |
If current_element$ = "description" Then mui.Set("channel_description", "Contents", tf_Label(str$)) |
If current_element$ = "description" Then mui.Set("channel_description", "Contents", tf_Label(str$)) |
145 |
183 |
|
|
146 |
|
else |
|
147 |
|
If current_element$ = "title" Then current_item.title = tf_Label(str$) |
|
148 |
|
If current_element$ = "pubDate" Then current_item.pubdate = tf_Label(str$) |
|
149 |
|
If current_element$ = "description" Then current_item.description = current_item.description ..str$ |
|
150 |
|
If current_element$ = "category" |
|
|
184 |
|
Else |
|
185 |
|
Switch current_element$ |
|
186 |
|
Case "title": current_item.title = tf_Label(str$) |
|
187 |
|
|
|
188 |
|
;č číselné hodnoty se nějak špatně načítají. |
|
189 |
|
;č fakt je nějaký problém v tom serializatoru |
|
190 |
|
Case "guid": current_item.guid = "guid:" .. str$ |
|
191 |
|
Case "pubDate": current_item.pubdate = tf_Label(str$) |
|
192 |
|
Case "description": |
|
193 |
|
current_item.description = current_item.description ..str$ |
|
194 |
|
Case "category": |
151 |
195 |
If current_item.category = "" |
If current_item.category = "" |
152 |
196 |
current_item.category = tf_Label(str$) |
current_item.category = tf_Label(str$) |
153 |
197 |
Else |
Else |
154 |
198 |
current_item.category = current_item.category .. ", " .. tf_Label(str$) |
current_item.category = current_item.category .. ", " .. tf_Label(str$) |
155 |
199 |
EndIf |
EndIf |
156 |
|
Endif |
|
|
200 |
|
EndSwitch |
157 |
201 |
EndIf |
EndIf |
158 |
202 |
EndFunction |
EndFunction |
159 |
203 |
|
|