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
e9db60b8
Commit
e9db60b8
authored
Mar 27, 2019
by
Administrator
💬
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for polyglot columns.
We still need a proper flag for the rosetta stone.
parent
35bdf614
Pipeline
#52
passed with stage
in 45 seconds
Changes
10
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
235 additions
and
8 deletions
+235
-8
m3-p2.php
user/plugins/m3-p2/m3-p2.php
+72
-4
m3-p2.yaml
user/plugins/m3-p2/m3-p2.yaml
+3
-2
polyglot-columns.md
user/plugins/m3-p2/pages/polyglot-columns.md
+0
-0
columns.html.twig
user/themes/textbook/templates/columns.html.twig
+9
-0
language-columns.html.twig
user/themes/textbook/templates/language-columns.html.twig
+24
-1
base.html.twig
user/themes/textbook/templates/partials/base.html.twig
+5
-1
language-selector.html.twig
...s/textbook/templates/partials/language-selector.html.twig
+65
-0
polyglot-columns.html.twig
user/themes/textbook/templates/polyglot-columns.html.twig
+33
-0
topic.html.twig
user/themes/textbook/templates/topic.html.twig
+6
-0
topics.html.twig
user/themes/textbook/templates/topics.html.twig
+18
-0
No files found.
user/plugins/m3-p2/m3-p2.php
View file @
e9db60b8
...
@@ -2,7 +2,10 @@
...
@@ -2,7 +2,10 @@
namespace
Grav\Plugin
;
namespace
Grav\Plugin
;
use
Grav\Common\Page\Page
;
use
Grav\Common\Page\Page
;
use
Grav\Common\Page\Pages
;
use
Grav\Common\Plugin
;
use
Grav\Common\Plugin
;
use
Grav\Common\Uri
;
use
Symfony\Component\EventDispatcher\Event
;
/**
/**
* Features:
* Features:
...
@@ -40,10 +43,12 @@ class M3P2Plugin extends Plugin
...
@@ -40,10 +43,12 @@ class M3P2Plugin extends Plugin
return
;
return
;
}
}
// /sync
$uri
=
$this
->
grav
[
'uri'
];
$uri
=
$this
->
grav
[
'uri'
];
$route
=
$this
->
config
->
get
(
'plugins.m3-p2.route'
);
$current_route
=
$uri
->
path
();
if
(
$route
&&
$route
==
$uri
->
path
())
{
// /sync
$route_sync
=
$this
->
config
->
get
(
'plugins.m3-p2.routes.sync'
);
if
(
$route_sync
&&
$route_sync
==
$current_route
)
{
$this
->
enable
([
$this
->
enable
([
'onPageInitialized'
=>
[
'onSyncPageInitialized'
,
0
]
'onPageInitialized'
=>
[
'onSyncPageInitialized'
,
0
]
]);
]);
...
@@ -52,6 +57,24 @@ class M3P2Plugin extends Plugin
...
@@ -52,6 +57,24 @@ class M3P2Plugin extends Plugin
$this
->
enable
([
$this
->
enable
([
'onTwigInitialized'
=>
[
'setupWebIdeUrl'
,
0
],
'onTwigInitialized'
=>
[
'setupWebIdeUrl'
,
0
],
]);
]);
// $that_page_route = $uri->query('page');
// if ($that_page_route) {
// $this->enable([
// 'onPageNotFound' => ['setupQueryPage', 0],
// ]);
// }
$this
->
enable
([
'onPageNotFound'
=>
[
'perhapsDisplayPolyglotColumns'
,
1
],
]);
// if ("" == $current_route) {
// $this->enable([
// 'onPageInitialized' => ['onSyncPageInitialized', 0]
// ]);
// }
}
}
/**
/**
...
@@ -83,9 +106,21 @@ class M3P2Plugin extends Plugin
...
@@ -83,9 +106,21 @@ class M3P2Plugin extends Plugin
);
);
}
}
public
function
setupQueryPage
()
{
$that_page_route
=
$this
->
grav
[
'uri'
]
->
query
(
'page'
);
// die($that_page_route);
var_dump
(
$that_page_route
);
$that_page
=
$this
->
grav
[
'pages'
]
->
find
(
$that_page_route
);
var_dump
(
$that_page
);
$this
->
grav
[
'twig'
]
->
twig
()
->
addGlobal
(
'that_page'
,
$that_page
);
}
public
function
getWebIdeUrlForPage
(
Page
$page
)
public
function
getWebIdeUrlForPage
(
Page
$page
)
{
{
$url
=
"https://m3p2.ljbac.com/-/ide/project/m3p2/courses/edit/master/-/"
;
$url
=
"https://m3p2.ljbac.com/-/ide/project/m3p2/courses/edit/master/-/"
;
# todo: move to YAML config
$url
.=
substr
(
$page
->
filePathClean
(),
11
);
// 11==strlen('/user/pages')
$url
.=
substr
(
$page
->
filePathClean
(),
11
);
// 11==strlen('/user/pages')
return
$url
;
return
$url
;
...
@@ -144,4 +179,37 @@ class M3P2Plugin extends Plugin
...
@@ -144,4 +179,37 @@ class M3P2Plugin extends Plugin
return
$translations
;
return
$translations
;
}
}
public
function
perhapsDisplayPolyglotColumns
(
Event
$event
)
{
/** @var Uri $uri */
$uri
=
$this
->
grav
[
'uri'
];
// var_dump($uri); // best doc ftw
if
(
"polyglot-columns"
!=
$uri
->
paths
(
0
))
{
return
;
// perhaps not
}
/** @var Pages $pages */
$pages
=
$this
->
grav
[
'pages'
];
$that_page_route
=
"/"
.
join
(
"/"
,
array_slice
(
$uri
->
paths
(),
1
));
// var_dump($that_page_route);
$target_page
=
$pages
->
find
(
$that_page_route
);
if
(
!
$target_page
)
{
return
;
}
$this
->
grav
[
'twig'
]
->
twig
()
->
addGlobal
(
'target_page'
,
$target_page
);
$page
=
new
Page
;
$page
->
init
(
new
\SplFileInfo
(
__DIR__
.
'/pages/polyglot-columns.md'
));
// here: perhaps add a title and other metadata
$event
->
page
=
$page
;
$event
->
stopPropagation
();
}
}
}
user/plugins/m3-p2/m3-p2.yaml
View file @
e9db60b8
enabled
:
true
enabled
:
true
#text_var: Custom Text added by the **M3p2** plugin (disable plugin to remove)
routes
:
route
:
"
/sync"
# Homemade git-sync, with not as much features.
sync
:
"
/sync"
user/plugins/m3-p2/pages/polyglot-columns.md
0 → 100644
View file @
e9db60b8
user/themes/textbook/templates/columns.html.twig
View file @
e9db60b8
...
@@ -19,3 +19,12 @@
...
@@ -19,3 +19,12 @@
</div>
</div>
{#
{{
page.content|raw }}#}
{#
{{
page.content|raw }}#}
{%
endblock
%}
{%
endblock
%}
{# Disable the Rosetta option of the language selector, for now. #}
{# How to access the Rosettas of the children poages? #}
{%
block
header_language_selection
%}
{%
embed
'partials/language-selector.html.twig'
%}
{%
block
polyglot_language_selector
%}{%
endblock
%}
{%
endembed
%}
{%
endblock
%}
user/themes/textbook/templates/language-columns.html.twig
View file @
e9db60b8
{%
extends
'partials/base.html.twig'
%}
{# DEPRECATED -- see polyglot-columns #}
{%
extends
'partials/base.html.twig'
%}
{%
block
stylesheets
%}
{%
block
stylesheets
%}
{%
do
assets.addCss
(
'theme://css/columns.css'
)
%}
{%
do
assets.addCss
(
'theme://css/columns.css'
)
%}
{{
parent
()
}}
{{
parent
()
}}
...
...
user/themes/textbook/templates/partials/base.html.twig
View file @
e9db60b8
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
{{
assets.css
()
|
raw
}}
{{
assets.css
()
|
raw
}}
{%
block
javascripts
%}
{%
block
javascripts
%}
{# TODO: ZEPTO #}
{# TODO: ZEPTO
JS PLS
#}
{%
do
assets.addJs
(
'jquery'
,
101
)
%}
{%
do
assets.addJs
(
'jquery'
,
101
)
%}
{%
do
assets.addJs
(
'theme://js/jquery.treemenu.js'
,
{
group
:
'bottom'
}
)
%}
{%
do
assets.addJs
(
'theme://js/jquery.treemenu.js'
,
{
group
:
'bottom'
}
)
%}
{%
do
assets.addJs
(
'theme://js/site.js'
,
{
group
:
'bottom'
}
)
%}
{%
do
assets.addJs
(
'theme://js/site.js'
,
{
group
:
'bottom'
}
)
%}
...
@@ -59,11 +59,15 @@
...
@@ -59,11 +59,15 @@
</section>
</section>
{%
block
header_language_selection_section
%}
<section
class=
"navbar-section"
>
<section
class=
"navbar-section"
>
<div>
{# Wrapper div to make centering vertically easy #}
<div>
{# Wrapper div to make centering vertically easy #}
{%
block
header_language_selection
%}
{%
include
'partials/language-selector.html.twig'
%}
{%
include
'partials/language-selector.html.twig'
%}
{%
endblock
%}
</div>
</div>
</section>
</section>
{%
endblock
%}
</nav>
</nav>
</section>
</section>
</section>
</section>
...
...
user/themes/textbook/templates/partials/language-selector.html.twig
0 → 100644
View file @
e9db60b8
<div
class=
"language-selector"
>
<button
class=
"btn"
type=
"button"
data-dropdown=
"langSelectorList"
>
{%
if
language_display.button
==
'default'
or
language_display.button
==
'flag'
%}
<img
alt=
"
{{
native_name
(
language_selector.current
)
|
capitalize
}}
"
src=
"
{{
path_flags
~
language_selector.current
}}
.png"
/>
{%
endif
%}
{%
if
language_display.button
==
'default'
or
language_display.button
==
'name'
%}
{{
native_name
(
language_selector.current
)
|
capitalize
}}
{%
endif
%}
<i
class=
"fa fa-caret-down"
></i>
</button>
<ul
class=
"dropdown-menu"
id=
"langSelectorList"
>
{%
for
language
in
language_selector.languages
%}
{%
set
show_language
=
true
%}
{%
if
language
==
language_selector.current
%}
{%
set
lang_url
=
page.url
%}
{%
else
%}
{%
set
base_lang_url
=
base_url_simple
~
grav.language.getLanguageURLPrefix
(
language
)
%}
{%
set
lang_url
=
base_lang_url
~
language_selector.page_route
~
page.urlExtension
%}
{%
set
untranslated_pages_behavior
=
grav.config.plugins.language_selector.untranslated_pages_behavior
%}
{%
if
untranslated_pages_behavior
!=
'none'
%}
{%
set
translated_page
=
language_selector.translated_pages
[
language
]
%}
{%
if
(
not
translated_page
)
or
(
not
translated_page.published
)
%}
{%
if
untranslated_pages_behavior
==
'redirect'
%}
{%
set
lang_url
=
base_lang_url
~
'/'
%}
{%
elseif
untranslated_pages_behavior
==
'hide'
%}
{%
set
show_language
=
false
%}
{%
endif
%}
{%
endif
%}
{%
endif
%}
{%
endif
%}
{%
if
show_language
%}
<li>
<a
href=
"
{{
lang_url
~
uri.params
}}
"
>
{%
if
language_display.select
==
'default'
or
language_display.select
==
'flag'
%}
<img
alt=
"
{{
native_name
(
language
)
|
capitalize
}}
"
src=
"
{{
path_flags
~
language
}}
.png"
/>
{%
endif
%}
{%
if
language_display.select
==
'default'
or
language_display.select
==
'name'
%}
{{
native_name
(
language
)
|
capitalize
}}
{%
endif
%}
</a>
</li>
{%
endif
%}
{%
endfor
%}
{%
block
polyglot_language_selector
%}
{%
if
uri.paths
and
uri.paths
(
0
)
!=
"polyglot-columns"
%}
<li>
<a
href=
"
{{
'/polyglot-columns'
~
uri.path
}}
"
>
{%
if
language_display.select
==
'default'
or
language_display.select
==
'flag'
%}
<img
alt=
"Rosetta"
src=
"fr.png"
/>
{%
endif
%}
{%
if
language_display.select
==
'default'
or
language_display.select
==
'name'
%}
Rosetta
{%
endif
%}
</a>
</li>
{%
endif
%}
{%
endblock
%}
</ul>
</div>
user/themes/textbook/templates/polyglot-columns.html.twig
0 → 100644
View file @
e9db60b8
{%
extends
'partials/base.html.twig'
%}
{# page is irrelevant here #}
{# use target_page, injected by m3-p2 plugin #}
{%
block
stylesheets
%}
{%
do
assets.addCss
(
'theme://css/columns.css'
)
%}
{{
parent
()
}}
{%
endblock
%}
{%
block
javascripts
%}
{%
do
assets.addJs
(
'theme://js/syncscroll.js'
,
{
group
:
'bottom'
}
)
%}
{{
parent
()
}}
{%
endblock
%}
{%
block
body
%}
<div
class=
"claude-columns"
>
{%
for
column
in
target_page
|
translations
%}
<section
id=
"
{{
macro.pageLinkName
(
column.menu
)
}}
"
class=
"claude-column syncscroll"
name=
"language"
>
{{
column.content
|
raw
}}
{#
{
% include 'partials/contributions-incentive.html.twig' with
{
page: column} %}#}
</section>
{%
endfor
%}
</div>
{%
endblock
%}
{# Disable the language selector. #}
{%
block
header_language_selection
%}{%
endblock
%}
{# … disabling the whole section instead is semantically correct but it offsets the navigation. TBD #}
{#
{
% block header_language_selection_section %}
{
% endblock %}#}
user/themes/textbook/templates/topic.html.twig
View file @
e9db60b8
{%
extends
'blog.html.twig'
%}
{%
extends
'blog.html.twig'
%}
{# Disable the Rosetta option of the language selector. #}
{%
block
header_language_selection
%}
{%
embed
'partials/language-selector.html.twig'
%}
{%
block
polyglot_language_selector
%}{%
endblock
%}
{%
endembed
%}
{%
endblock
%}
\ No newline at end of file
user/themes/textbook/templates/topics.html.twig
View file @
e9db60b8
...
@@ -5,6 +5,12 @@
...
@@ -5,6 +5,12 @@
{{
parent
()
}}
{{
parent
()
}}
{%
endblock
%}
{%
endblock
%}
{%
block
javascripts
%}
{{
parent
()
}}
{%
do
assets.add
(
'theme://js/bricklayer.min.js'
)
%}
{%
do
assets.add
(
'theme://js/scopedQuerySelectorShim.min.js'
)
%}
{%
endblock
%}
{%
block
content
%}
{%
block
content
%}
{{
page.content
|
raw
}}
{{
page.content
|
raw
}}
...
@@ -13,4 +19,16 @@
...
@@ -13,4 +19,16 @@
{%
include
'partials/topic-list-item.html.twig'
with
{
parent
:
page
,
page
:
topic
}
%}
{%
include
'partials/topic-list-item.html.twig'
with
{
parent
:
page
,
page
:
topic
}
%}
{%
endfor
%}
{%
endfor
%}
</section>
</section>
<script>
//Bricklayer
var
bricklayer
=
new
Bricklayer
(
document
.
querySelector
(
'.bricklayer'
))
</script>
{%
endblock
%}
{# Disable the Rosetta option of the language selector. #}
{%
block
header_language_selection
%}
{%
embed
'partials/language-selector.html.twig'
%}
{%
block
polyglot_language_selector
%}{%
endblock
%}
{%
endembed
%}
{%
endblock
%}
{%
endblock
%}
\ No newline at end of file
Goutte
@Goutte
mentioned in issue
#7 (closed)
·
Mar 27, 2019
mentioned in issue
#7 (closed)
mentioned in issue #7
Toggle commit list
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