-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MDLSITE-7917: Frontpage editable blocks #18
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define([], function() { | ||
return { | ||
init: function(contributedstrings) { | ||
const contributedstringsElements = document.querySelectorAll('.contributedstrings'); | ||
contributedstringsElements.forEach(element => { | ||
element.textContent = contributedstrings; | ||
}); | ||
} | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
define([], function() { | ||
return { | ||
init: function(listcontributors) { | ||
const listcontributorsElements = document.querySelectorAll('.listcontributors'); | ||
listcontributorsElements.forEach(element => { | ||
element.innerHTML = listcontributors; | ||
}); | ||
} | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,54 +23,18 @@ | |
{} | ||
}} | ||
|
||
<h1 class="brandheader" style="margin: 1.5rem 0 0">Translation</h1> | ||
|
||
<div class="card-deck my-2"> | ||
<div class="card"> | ||
<div class="lead card-header">{{#str}} amos, local_amos {{/str}}</div> | ||
<div class="card-body"> | ||
<div>{{#str}} about, local_amos {{/str}}</div> | ||
</div> | ||
</div> | ||
<div class="card"> | ||
<div class="lead card-header">{{#str}} contribute, local_amos {{/str}}</div> | ||
<div class="card-body"> | ||
<p>{{#str}} contributestats, local_amos, {"count": {{#quote}} {{{contributedstrings}}} {{/quote}} } {{/str}}</p> | ||
<p>{{#str}} contributethanks, local_amos, { "listcontributors": {{#quote}} {{{listcontributors}}} {{/quote}} } {{/str}}</p> | ||
<p class="text-center"> | ||
<a class="btn btn-large btn-success" href="/local/amos/">{{#str}} contributenow, local_amos {{/str}}</a> | ||
<a class="btn btn-large btn-secondary" href="/local/amos/credits.php">{{#str}} creditstitleshort, local_amos {{/str}}</a> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="card"> | ||
<div class="lead card-header">{{#str}} quicklinks, local_amos {{/str}}</div> | ||
<div class="card-body"> | ||
<ul class="unstyled"> | ||
<li> | ||
<a href="/local/amos/view.php"> | ||
{{#str}} quicklinks_amos, local_amos {{/str}} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/course/view.php?id=2"> | ||
{{#str}} quicklinks_forum, local_amos {{/str}} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="/mod/page/view.php?id=9"> | ||
{{#str}} quicklinks_newcomers, local_amos {{/str}} | ||
</a> | ||
</li> | ||
<li> | ||
<a href="https://docs.moodle.org/dev/AMOS_manual"> | ||
{{#str}} quicklinks_manual, local_amos {{/str}} | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</div> | ||
{{#js}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need those scripts at all? Could not this simple replacement be put here into the JS section completely? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added it in the module to maintain the standard, replicating what I did in other JavaScript developments like this, related to the HTML content of Moodle.org pages. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, it is a fair argument. It just initially looked and felt as an overkill to me. But I agree it is how it should be by the book :-) |
||
{{#contributedstrings}} | ||
require(['local_amos/contributedstrings'], function(contributedstrings) { | ||
contributedstrings.init('{{{contributedstrings}}}'); | ||
}); | ||
{{/contributedstrings}} | ||
{{#listcontributors}} | ||
require(['local_amos/listcontributors'], function(listcontributors) { | ||
listcontributors.init('{{#str}} contributethanks, local_amos, { "listcontributors": {{#quote}} {{{listcontributors}}} {{/quote}} } {{/str}}'); | ||
}); | ||
{{/listcontributors}} | ||
{{/js}} | ||
|
||
<div class="card"> | ||
<div class="lead card-header">{{#str}} availablelangs, core_install {{/str}}</div> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that
is appropriate selector here. We should not use CSS selectors and identifiers for JS integration. An element that has special meaning for a JS (such as its content is provided like in this case) should be identified via
data
attribute. See https://moodledev.io/docs/5.0/guides/javascriptThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, my content comes from an HTML block, and moodle filters all these data attributes from this type of content.
This class actually is inside a
strong
tag. I tried to adddata-contributed-strings
, and the editor changes that todata-contributed-strings=""
but finally is filtered and disappears in the page, the same happens if I use an attribute with content likedata-contributed-strings="placeholder"
.¿Do you know how to change that from a class and works?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, right. I had forgotten that this is the user contents now and that it gets filtered. Ok, never mind then.