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
ca18e855
Commit
ca18e855
authored
Mar 24, 2019
by
Administrator
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP.
parent
b575a2b5
Pipeline
#50
passed with stage
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
m3-p2.php
user/plugins/m3-p2/m3-p2.php
+57
-0
language-columns.html.twig
user/themes/textbook/templates/language-columns.html.twig
+2
-1
No files found.
user/plugins/m3-p2/m3-p2.php
View file @
ca18e855
...
...
@@ -78,6 +78,9 @@ class M3P2Plugin extends Plugin
$this
->
grav
[
'twig'
]
->
twig
()
->
addFilter
(
new
\Twig_SimpleFilter
(
'webide_url'
,
[
$this
,
'getWebIdeUrlForPage'
])
);
$this
->
grav
[
'twig'
]
->
twig
()
->
addFilter
(
new
\Twig_SimpleFilter
(
'translations'
,
[
$this
,
'getTranslationsOfPage'
])
);
}
public
function
getWebIdeUrlForPage
(
Page
$page
)
...
...
@@ -87,4 +90,58 @@ class M3P2Plugin extends Plugin
return
$url
;
}
// public function getPage($route)
// {
// $page = null;
//// $translation_path = $page->path() . DS . $page_name_without_ext . '.' . $language . '.md';
// if (file_exists($translation_path)) {
// $page = new Page();
// $page->init(new \SplFileInfo($page_path), $language . '.md');
// }
//
// return $page;
// }
public
function
getTranslationsOfPage
(
Page
$page
)
{
$languages
=
$this
->
config
->
get
(
'system.languages.supported'
);
// die(print_r($languages));
$route_suffix
=
$page
->
rawRoute
();
$translations
=
array
();
$current_language
=
$page
->
language
();
$page_name_without_ext
=
substr
(
$page
->
name
(),
0
,
-
(
strlen
(
$page
->
extension
())));
foreach
(
$languages
as
$language
)
{
// $route = '/' . $language . $route_suffix;
// $route = $route_suffix;
// FIXME: nope. language-selector does this the hard way, by instantiating Page objects
//$translation = $page->find($route);
// … so we're falling back on the old school too
$translation_path
=
$page
->
path
()
.
DS
.
$page_name_without_ext
.
'.'
.
$language
.
'.md'
;
if
(
file_exists
(
$translation_path
))
{
$translation
=
new
Page
();
$translation
->
init
(
new
\SplFileInfo
(
$translation_path
),
$language
.
'.md'
);
// $translated_pages[$language] = $translation;
}
else
{
continue
;
}
// var_dump($route);
// die(var_dump($route));
// die(var_dump($translation));
if
(
$language
==
$current_language
)
{
array_unshift
(
$translations
,
$translation
);
}
else
{
array_push
(
$translations
,
$translation
);
}
}
// die(var_dump($translations));
return
$translations
;
}
}
user/themes/textbook/templates/language-columns.html.twig
View file @
ca18e855
...
...
@@ -15,7 +15,8 @@
{%
block
body
%}
<div
class=
"claude-columns"
>
{%
for
column
in
language_selector.translated_pages
%}
{%
for
column
in
page
|
translations
%}
{#
{
% for column in language_selector.translated_pages %}#}
<section
id=
"
{{
macro.pageLinkName
(
column.menu
)
}}
"
class=
"claude-column syncscroll"
name=
"language"
>
{{
column.content
|
raw
}}
{#
{
% include 'partials/contributions-incentive.html.twig' with
{
page: column} %}#}
...
...
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