Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
FediBlog
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Libeau
FediBlog
Commits
8c60b1a6
Commit
8c60b1a6
authored
May 20, 2018
by
David Libeau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add first *in the content* function to list all the articles and render them in a specific view
parent
a166daba
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
7 deletions
+48
-7
fedicore/controllers/Core.php
fedicore/controllers/Core.php
+5
-0
fedicore/controllers/View.php
fedicore/controllers/View.php
+36
-7
static/index.txt
static/index.txt
+7
-0
No files found.
fedicore/controllers/Core.php
View file @
8c60b1a6
...
...
@@ -226,6 +226,11 @@ $feed='<?xml version="1.0" encoding="utf-8"?>
$return
.=
$object
->
exportAtom
();
}
break
;
default
:
foreach
(
$objects
as
$object
)
{
$return
.=
View
::
render
(
$format
,
$object
,
"return"
);
}
break
;
}
return
(
$return
);
}
...
...
fedicore/controllers/View.php
View file @
8c60b1a6
<?php
class
View
{
public
static
function
render
(
$viewName
,
$object
)
{
public
static
function
render
(
$viewName
,
$object
,
$returnMethod
=
"echo"
)
{
global
$core
;
/*
Render view
*/
switch
(
$viewName
){
case
"raw"
:
...
...
@@ -44,13 +47,16 @@ echo('<?xml version="1.0" encoding="utf-8"?>
'
.
$object
->
exportAtom
()
.
'
</feed>'
);
break
;
case
"htmlSummary"
:
$render
=
"<a href=
\"
/"
.
Server
::
get
(
"route/content/"
.
$object
->
get
(
"type"
))
.
"/"
.
$object
->
get
(
"id"
)
.
"
\"
>"
.
$object
->
get
(
"id"
)
.
"</a>"
;
break
;
default
:
$
view
=
file_get_contents
(
"views/"
.
$viewName
.
".xml"
);
if
(
$
view
==
false
){
$
render
=
file_get_contents
(
"views/"
.
$viewName
.
".xml"
);
if
(
$
render
==
false
){
$core
->
error
(
"404"
,
"View named
\"
$viewName
\"
was not found"
);
}
//TO DO : Transform xml to html via the base template here
preg_match_all
(
"/\{\{([^\}]*)\}\}/"
,
$
view
,
$matches
);
//isolate {{this thing}}
preg_match_all
(
"/\{\{([^\}]*)\}\}/"
,
$
render
,
$matches
);
//isolate {{this thing}} in the view
foreach
(
$matches
[
1
]
as
$i
=>
$m
){
if
(
preg_match
(
"/(.+\(.+\).*)
{
1
}
/"
,
$m
))
{
$vfunction
=
strtolower
(
explode
(
"("
,
$m
)[
0
]);
...
...
@@ -59,17 +65,40 @@ echo('<?xml version="1.0" encoding="utf-8"?>
if
(
$vfunction
==
"markdown"
||
$vfunction
==
"parsedown"
){
$Parsedown
=
new
Parsedown
();
if
(
$vparam
[
0
]
==
"$"
){
$view
=
str_replace
(
$matches
[
0
][
$i
],
$Parsedown
->
text
(
$object
->
get
(
substr
(
$vparam
,
1
))),
$view
);
$render
=
str_replace
(
$matches
[
0
][
$i
],
$Parsedown
->
text
(
$object
->
get
(
substr
(
$vparam
,
1
))),
$render
);
//Check for {{things}} in the rendered view
preg_match_all
(
"/\{\{([^\}]*)\}\}/"
,
$render
,
$matches
);
//isolate {{this thing}}
foreach
(
$matches
[
1
]
as
$i
=>
$m
){
if
(
preg_match
(
"/(.+\(.+\).*)
{
1
}
/"
,
$m
))
{
$vfunction
=
strtolower
(
explode
(
"("
,
$m
)[
0
]);
$vparam
=
str_replace
(
")"
,
""
,
explode
(
"("
,
$m
)[
1
]);
if
(
$vfunction
==
"list"
){
$vparam
=
explode
(
","
,
$vparam
);
if
(
$vparam
[
0
]
==
"all"
){
$render
=
str_replace
(
$matches
[
0
][
$i
],
$core
->
listAll
(
$vparam
[
1
],
$vparam
[
2
]),
$render
);
}
elseif
(
$vparam
[
0
][
1
]
==
"@"
){
//user
}
}
}
}
}
}
}
if
(
$m
[
0
]
==
"$"
){
$
view
=
str_replace
(
$matches
[
0
][
$i
],
Secure
::
that
(
$object
->
get
(
substr
(
$m
,
1
))),
$view
);
$
render
=
str_replace
(
$matches
[
0
][
$i
],
$object
->
get
(
substr
(
$m
,
1
)),
$render
);
}
}
echo
(
$view
);
break
;
}
//If not already return or echo (?)
if
(
$returnMethod
==
"echo"
){
echo
(
Secure
::
that
(
$render
));
}
elseif
(
$returnMethod
==
"return"
){
return
(
Secure
::
that
(
$render
));
}
}
}
?>
\ No newline at end of file
static/index.txt
0 → 100644
View file @
8c60b1a6
# dev.fedi.blog
Hello world.
**This is a list of all articles :**
{{list(all,article,htmlSummary)}}
\ No newline at end of file
Write
Preview
Markdown
is supported
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