Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
dotgreg
tiro-notes
Commits
1826d6bf
Commit
1826d6bf
authored
May 22, 2022
by
greg@1m
Browse files
rss filter
parent
534203b4
Changes
4
Hide whitespace changes
Inline
Side-by-side
client/src/hooks/api/api.hook.tsx
View file @
1826d6bf
...
...
@@ -28,9 +28,16 @@ export interface iApiEventBus {
unsubscribe
:
(
reqId
:
string
)
=>
void
notify
:
(
reqId
:
string
,
answer
:
any
)
=>
void
}
/**
* woop woooop test2
*/
export
interface
iClientApi
{
file
:
iFileApi
upload
:
iUploadApi
/**
* comment3
*/
popup
:
iPopupApi
files
:
iFilesApi
folders
:
iFoldersApi
...
...
client/src/hooks/app/usePromptPopup.hook.tsx
View file @
1826d6bf
...
...
@@ -11,14 +11,27 @@ const liveVars: {
onRefuse
:
()
=>
{
},
}
/**
* comment5
*/
export
type
iPrompt
=
(
p
:
{
text
:
string
,
title
?:
string
,
onAccept
?:
Function
,
onRefuse
?:
Function
})
=>
void
export
type
iConfirmPopup
=
(
text
:
string
,
cb
:
Function
)
=>
void
export
type
iPopupApi
=
{
confirm
:
iConfirmPopup
,
prompt
:
iPrompt
}
/**
* comment4
*/
export
type
iConfirmPopup
=
(
text
:
string
,
cb
:
Function
,
onRefuse
?:
Function
)
=>
void
export
type
iPopupApi
=
{
confirm
:
iConfirmPopup
,
prompt
:
iPrompt
}
export
const
PopupContext
=
React
.
createContext
<
iPopupApi
|
null
>
(
null
);
export
const
usePromptPopup
=
(
p
:
{
...
...
@@ -30,7 +43,7 @@ export const usePromptPopup = (p: {
const
[
title
,
setTitle
]
=
useState
(
strings
.
promptPopup
.
defaultTitle
)
const
[
showRefuse
,
setShowRefuse
]
=
useState
(
false
)
const
confirmPopup
:
iConfirmPopup
=
(
text
,
cb
,
onRefuse
?:
Function
)
=>
{
const
confirmPopup
:
iConfirmPopup
=
(
text
,
cb
,
onRefuse
)
=>
{
promptPopup
({
title
:
strings
.
promptPopup
.
confirmTitle
,
...
...
client/src/managers/iframe.manager.ts
View file @
1826d6bf
...
...
@@ -5,10 +5,6 @@ import { iFile, iFileNature } from "../../../shared/types.shared";
import
{
createEventBus
,
iEventBusMessage
}
from
"
./eventBus.manager
"
;
import
{
replaceCustomMdTags
}
from
"
./markdown.manager
"
;
import
{
unescapeHtml
}
from
"
./textProcessor.manager
"
;
import
{
iFileApi
}
from
"
../hooks/api/file.api.hook
"
;
import
{
iFilesApi
}
from
"
../hooks/api/files.api.hook
"
;
import
{
iPopupApi
}
from
"
../hooks/app/usePromptPopup.hook
"
;
import
{
getClientApi2
,
iClientApi
}
from
"
../hooks/api/api.hook
"
;
type
iIframeActions
=
'
init
'
|
'
apiCall
'
|
'
apiAnswer
'
|
'
resize
'
|
'
iframeError
'
...
...
custom-tags/rss/rss.js
View file @
1826d6bf
...
...
@@ -33,35 +33,35 @@ const rssApp = (innerTagStr, opts) => {
let
count
=
0
for
(
let
i
=
0
;
i
<
feedsArr
.
length
;
i
++
)
{
fetch
(
`
${
urlApi
}${
feedsArr
[
i
].
url
}
`
)
.
then
(
response
=>
{
return
response
.
json
()
})
.
then
(
data
=>
{
count
=
count
+
1
console
.
log
(
h
,
"
1 debug els
"
,
feedsArr
[
i
].
url
,
data
,
count
,
feedsArr
.
length
)
.
then
(
response
=>
{
return
response
.
json
()
})
.
then
(
data
=>
{
count
=
count
+
1
console
.
log
(
h
,
"
1 debug els
"
,
feedsArr
[
i
].
url
,
data
,
count
,
feedsArr
.
length
)
if
(
Array
.
isArray
(
data
.
items
))
{
const
nitems
=
[...
data
.
items
]
for
(
let
j
=
0
;
j
<
nitems
.
length
;
j
++
)
{
nitems
[
j
].
sourceRss
=
feedsArr
[
i
].
name
const
timestamp
=
Date
.
parse
(
nitems
[
j
].
pubDate
)
const
d
=
new
Date
(
timestamp
)
//const datestring = d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes();
const
datestring
=
d
.
getDate
()
+
"
/
"
+
(
d
.
getMonth
()
+
1
)
+
"
"
+
d
.
getHours
()
+
"
:
"
+
d
.
getMinutes
();
if
(
Array
.
isArray
(
data
.
items
))
{
const
nitems
=
[...
data
.
items
]
for
(
let
j
=
0
;
j
<
nitems
.
length
;
j
++
)
{
nitems
[
j
].
sourceRss
=
feedsArr
[
i
].
name
const
timestamp
=
Date
.
parse
(
nitems
[
j
].
pubDate
)
const
d
=
new
Date
(
timestamp
)
//const datestring = d.getDate() + "-" + (d.getMonth()+1) + "-" + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes();
const
datestring
=
d
.
getDate
()
+
"
/
"
+
(
d
.
getMonth
()
+
1
)
+
"
"
+
d
.
getHours
()
+
"
:
"
+
d
.
getMinutes
();
nitems
[
j
].
timestamp
=
timestamp
nitems
[
j
].
smallDate
=
datestring
resItems
.
push
(
nitems
[
j
])
}
}
if
(
count
===
feedsArr
.
length
)
{
// sort items by time
console
.
log
(
h
,
"
2: outputting elements taken from api
"
)
resItems
=
resItems
.
sort
((
a
,
b
)
=>
b
.
timestamp
-
a
.
timestamp
)
cb
(
resItems
)
}
nitems
[
j
].
timestamp
=
timestamp
nitems
[
j
].
smallDate
=
datestring
resItems
.
push
(
nitems
[
j
])
}
}
if
(
count
===
feedsArr
.
length
)
{
// sort items by time
console
.
log
(
h
,
"
2: outputting elements taken from api
"
)
resItems
=
resItems
.
sort
((
a
,
b
)
=>
b
.
timestamp
-
a
.
timestamp
)
cb
(
resItems
)
}
});
});
}
}
...
...
@@ -70,12 +70,12 @@ const rssApp = (innerTagStr, opts) => {
const
[
type
,
setType
]
=
React
.
useState
(
"
text
"
)
React
.
useEffect
(()
=>
{
// for mp3/podcasts
if
(
p
.
article
.
enclosure
.
type
&&
p
.
article
.
enclosure
.
type
.
includes
(
"
audio
"
)
)
setType
(
"
audio
"
)
},
[
p
.
article
])
// for mp3/podcasts
if
(
p
.
article
.
enclosure
.
type
&&
p
.
article
.
enclosure
.
type
.
includes
(
"
audio
"
)
)
setType
(
"
audio
"
)
},
[
p
.
article
])
const
bgColors
=
[
"
#264653
"
,
"
#2A9D8F
"
,
"
#E9C46A
"
,
"
#F4A261
"
,
"
#E76F51
"
]
...
...
@@ -87,74 +87,114 @@ const rssApp = (innerTagStr, opts) => {
return
(
c
(
'
div
'
,
{
className
:
"
article-details-wrapper
"
},
[
c
(
'
div
'
,
{
className
:
"
article-close
"
,
onClick
:
()
=>
{
p
.
onClose
()
}
},
[
"
x
"
]),
c
(
'
div
'
,
{
className
:
"
article-title
"
},
[
p
.
article
.
title
]),
c
(
'
div
'
,
{
className
:
"
bg-image
"
,
style
:
{
backgroundImage
:
"
url(
"
+
bgImage
+
"
)
"
,
backgroundColor
:
cColor
}
}),
c
(
'
div
'
,
{
className
:
"
article-content-wrapper
"
},
[
c
(
'
div
'
,
{
className
:
"
article-time
"
},
[
p
.
article
.
pubDate
+
"
-
"
+
p
.
article
.
sourceRss
]),
c
(
'
div
'
,
{
className
:
"
article-description
"
,
dangerouslySetInnerHTML
:
{
__html
:
p
.
article
.
description
}
}),
c
(
'
br
'
),
p
.
article
.
content
!==
p
.
article
.
description
&&
c
(
'
div
'
,
{
className
:
"
article-description
"
,
dangerouslySetInnerHTML
:
{
__html
:
p
.
article
.
content
}
}),
c
(
'
div
'
,
{
className
:
"
article-close
"
,
onClick
:
()
=>
{
p
.
onClose
()
}
},
[
"
x
"
]),
c
(
'
div
'
,
{
className
:
"
article-title
"
},
[
p
.
article
.
title
]),
c
(
'
div
'
,
{
className
:
"
bg-image
"
,
style
:
{
backgroundImage
:
"
url(
"
+
bgImage
+
"
)
"
,
backgroundColor
:
cColor
}
}),
c
(
'
div
'
,
{
className
:
"
article-content-wrapper
"
},
[
c
(
'
div
'
,
{
className
:
"
article-time
"
},
[
p
.
article
.
pubDate
+
"
-
"
+
p
.
article
.
sourceRss
]),
type
!==
"
audio
"
&&
c
(
'
a
'
,
{
className
:
"
article-link
"
,
href
:
p
.
article
.
link
,
target
:
"
_blank
"
},
[
"
link
"
]),
type
===
"
audio
"
&&
c
(
'
div
'
,
{
className
:
"
audio-wrapper
"
,
},
[
c
(
'
audio
'
,
{
controls
:
"
true
"
},
[
c
(
'
source
'
,
{
src
:
p
.
article
.
enclosure
.
link
,
type
:
p
.
article
.
enclosure
.
type
})
]),
c
(
'
a
'
,
{
className
:
"
article-link
"
,
href
:
p
.
article
.
enclosure
.
link
,
target
:
"
_blank
"
},
[
"
audio file
"
]),
])
])
c
(
'
div
'
,
{
className
:
"
article-description
"
,
dangerouslySetInnerHTML
:
{
__html
:
p
.
article
.
description
}
}),
c
(
'
br
'
),
p
.
article
.
content
!==
p
.
article
.
description
&&
c
(
'
div
'
,
{
className
:
"
article-description
"
,
dangerouslySetInnerHTML
:
{
__html
:
p
.
article
.
content
}
}),
]),
type
!==
"
audio
"
&&
c
(
'
a
'
,
{
className
:
"
article-link
"
,
href
:
p
.
article
.
link
,
target
:
"
_blank
"
},
[
"
link
"
]),
type
===
"
audio
"
&&
c
(
'
div
'
,
{
className
:
"
audio-wrapper
"
,
},
[
c
(
'
audio
'
,
{
controls
:
"
true
"
},
[
c
(
'
source
'
,
{
src
:
p
.
article
.
enclosure
.
link
,
type
:
p
.
article
.
enclosure
.
type
})
]),
c
(
'
a
'
,
{
className
:
"
article-link
"
,
href
:
p
.
article
.
enclosure
.
link
,
target
:
"
_blank
"
},
[
"
audio file
"
]),
])
])
)
};
const
App
=
()
=>
{
const
titems
=
React
.
useRef
([])
const
[
items
,
setItems
]
=
React
.
useState
([])
const
[
filteredItems
,
setFilteredItems
]
=
React
.
useState
([])
const
[
itemActive
,
setItemActive
]
=
React
.
useState
(
null
)
const
[
feeds
,
setFeeds
]
=
React
.
useState
([])
const
[
activeFeed
,
setActiveFeed
]
=
React
.
useState
(
"
all
"
)
React
.
useEffect
(()
=>
{
getJsons
(
nitems
=>
{
const
i
=
[...
nitems
]
setItems
(
i
)
titems
.
current
=
i
const
nfeeds
=
[]
for
(
let
i
=
0
;
i
<
nitems
.
length
;
i
++
)
{
const
it
=
nitems
[
i
];
if
(
!
nfeeds
.
includes
(
it
.
sourceRss
))
nfeeds
.
push
(
it
.
sourceRss
)
}
setFeeds
(
nfeeds
)
setActiveFeed
(
null
)
// console.log(223331,nitems, titems.current);
})
},
[])
React
.
useEffect
(()
=>
{
getJsons
(
nitems
=>
{
const
i
=
[...
nitems
]
setItems
(
i
)
})
},
[])
const
nitems
=
[]
for
(
let
i
=
0
;
i
<
items
.
length
;
i
++
)
{
const
it
=
items
[
i
];
if
(
activeFeed
===
null
)
nitems
.
push
(
it
)
else
if
(
it
.
sourceRss
===
activeFeed
)
nitems
.
push
(
it
)
}
setFilteredItems
(
nitems
)
// console.log(22333,nitems, activeFeed, items, titems.current);
},[
activeFeed
])
return
(
c
(
'
div
'
,
{
className
:
"
rss-app-wrapper
"
},
[
c
(
'
div
'
,
{
className
:
`articles-list
${
itemActive
?
'
item-active-open
'
:
''
}
`
},
[
items
.
map
(
item
=>
c
(
'
div
'
,
{
className
:
"
article-list-item
"
,
onClick
:
()
=>
{
setItemActive
(
item
)
}
},
[
`[
${
item
.
sourceRss
}
${
item
.
smallDate
}
]
${
item
.
title
}
`
]
),
)
c
(
'
div
'
,
{
className
:
`filter-list-wrapper`
},
[
c
(
'
select
'
,
{
onChange
:
e
=>
{
let
val
=
e
.
target
.
value
if
(
val
===
"
all
"
)
val
=
null
setActiveFeed
(
val
)
console
.
log
(
223331
,
val
);
}},
[
c
(
'
option
'
,
{
value
:
"
all
"
},
[
`all`
]),
feeds
.
map
(
feed
=>
c
(
'
option
'
,
{
value
:
feed
},
[
`
${
feed
}
`
])
)
]),
]),
c
(
'
div
'
,
{
className
:
`articles-list
${
itemActive
?
'
item-active-open
'
:
''
}
`
},
[
filteredItems
.
map
(
item
=>
c
(
'
div
'
,
{
className
:
"
article-list-item
"
,
onClick
:
()
=>
{
setItemActive
(
item
)
}
},
[
`[
${
item
.
sourceRss
}
${
item
.
smallDate
}
]
${
item
.
title
}
`
]
),
)
]),
itemActive
&&
c
(
ArticleDetail
,
{
article
:
itemActive
,
onClose
:
()
=>
{
setItemActive
(
null
)
}
},
[]),
])
itemActive
&&
c
(
ArticleDetail
,
{
article
:
itemActive
,
onClose
:
()
=>
{
setItemActive
(
null
)
}
},
[]),
])
);
}
...
...
@@ -173,8 +213,8 @@ const rssApp = (innerTagStr, opts) => {
console
.
log
(
h
,
"
0: react loaded, starting script with innertag:
"
,
innerTagStr
)
execRssReader
(
innerTagStr
)
setTimeout
(()
=>
{
api
.
utils
.
resizeIframe
(
opts
.
size
);
},
100
);
api
.
utils
.
resizeIframe
(
opts
.
size
);
},
100
);
}
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment