Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M3P2 HTML Generator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
12
Issues
12
List
Board
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
M3P2
M3P2 HTML Generator
Commits
dba3b33f
Commit
dba3b33f
authored
Mar 21, 2019
by
Administrator
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor how we link to the web ide.
parent
e4f4a6ac
Pipeline
#41
passed with stage
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
10 deletions
+27
-10
m3-p2.php
user/plugins/m3-p2/m3-p2.php
+26
-8
textbook.html.twig
user/themes/textbook/templates/textbook.html.twig
+1
-2
No files found.
user/plugins/m3-p2/m3-p2.php
View file @
dba3b33f
...
@@ -40,25 +40,28 @@ class M3P2Plugin extends Plugin
...
@@ -40,25 +40,28 @@ class M3P2Plugin extends Plugin
return
;
return
;
}
}
// /sync
$uri
=
$this
->
grav
[
'uri'
];
$uri
=
$this
->
grav
[
'uri'
];
$route
=
$this
->
config
->
get
(
'plugins.m3-p2.route'
);
$route
=
$this
->
config
->
get
(
'plugins.m3-p2.route'
);
// throw new \Exception($route." - ".$uri->path());
if
(
$route
&&
$route
==
$uri
->
path
())
{
if
(
$route
&&
$route
==
$uri
->
path
())
{
$this
->
enable
([
$this
->
enable
([
'onPageInitialized'
=>
[
'onPageInitialized'
,
0
]
'onPageInitialized'
=>
[
'on
Sync
PageInitialized'
,
0
]
]);
]);
}
}
$this
->
enable
([
'onTwigInitialized'
=>
[
'setupWebIdeUrl'
,
0
],
]);
}
}
/**
/**
* S
end user to a random page
* S
ync with the sources.
*/
*/
public
function
onPageInitialized
()
public
function
on
Sync
PageInitialized
()
{
{
$out
=
"Opening a fortune cookie…
\n\n\n
"
;
// shell cwd is project root
// shell pwd is project root
$out
=
"Opening a fortune cookie…
\n\n\n
"
;
// $out .= shell_exec("fortune | cowsay -e Oø -f dragon") . "\n";
// $out .= shell_exec("fortune | cowsay -e Oø -f dragon") . "\n";
$out
.=
shell_exec
(
"fortune"
)
.
"
\n\n
"
;
$out
.=
shell_exec
(
"fortune"
)
.
"
\n\n
"
;
...
@@ -67,6 +70,21 @@ class M3P2Plugin extends Plugin
...
@@ -67,6 +70,21 @@ class M3P2Plugin extends Plugin
$out
.=
"Done."
;
$out
.=
"Done."
;
die
(
"<pre>"
.
$out
.
"</pre>"
);
// This is all I find to write to the page.
die
(
"<pre>"
.
$out
.
"</pre>"
);
// This is all I could find to write to the page.
}
public
function
setupWebIdeUrl
()
{
$this
->
grav
[
'twig'
]
->
twig
()
->
addFilter
(
new
\Twig_SimpleFilter
(
'webide_url'
,
[
$this
,
'getWebIdeUrlForPage'
])
);
}
public
function
getWebIdeUrlForPage
(
Page
$page
)
{
$url
=
"https://m3p2.ljbac.com/-/ide/project/m3p2/courses/edit/master/-/"
;
$url
.=
substr
(
$page
->
filePathClean
(),
11
);
// 11==strlen('/user/pages')
return
$url
;
}
}
}
}
user/themes/textbook/templates/textbook.html.twig
View file @
dba3b33f
...
@@ -4,12 +4,11 @@
...
@@ -4,12 +4,11 @@
{{
page.content
|
raw
}}
{{
page.content
|
raw
}}
{%
set
editor_url
=
"https://m3p2.ljbac.com/-/ide/project/m3p2/courses/edit/master/-/"
~
page.filePathClean
|
slice
(
11
)
%}
<div
class=
"notices blue contribution-incentive"
>
<div
class=
"notices blue contribution-incentive"
>
<p>
<p>
{{
'THEME_TEXTBOOK.PAGE.FOOTER_NOTICE.CONGRATULATIONS'
|
t
}}
{{
'THEME_TEXTBOOK.PAGE.FOOTER_NOTICE.CONGRATULATIONS'
|
t
}}
<a
href=
"
{{
editor
_url
}}
"
>
{{
'THEME_TEXTBOOK.PAGE.FOOTER_NOTICE.EDIT'
|
t
}}
</a>
<a
href=
"
{{
page
|
webide
_url
}}
"
>
{{
'THEME_TEXTBOOK.PAGE.FOOTER_NOTICE.EDIT'
|
t
}}
</a>
</p>
</p>
</div>
</div>
{%
endblock
%}
{%
endblock
%}
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