MediaWiki Semantic Template: Property "Title" (as page type) with input value - mediawiki

A few months ago I asked a very similar question but the cause of the problem this time is different.
The error message is:
Property "Title" (as page type) with input value "Lo psicologo di base rischia di essere inutile se non ci sono abbastanza fondi stanziati
italianTitle = {{{italianTitle}}}" contains invalid characters or is incomplete and therefore can cause unexpected results during a query or annotation process.
Here I'm using an {{#if inside a template.
The property italianTitle is optional
<includeonly>[{{{url}}} {{#if:{{{italianTitle|}}}|{{{italianTitle}}}|{{{title}}}}}] - {{{tags}}} {{#subobject:
|url = {{{url}}}
|title = {{{title}}}
{{#if:{{{italianTitle|}}}|
|italianTitle = {{{italianTitle}}}
}}
|tags={{{tags}}}|+sep=,}}</includeonly>
<noinclude>
{{man}}
== Esempi:==
{{SemanticLink|url=https://www.instagram.com/p/CY_t7QhIWTD/|title=Lo psicologo di base rischia di essere inutile se non ci sono abbastanza fondi stanziati|tags=psicologia,governo,politica,lavoro}}
{{SemanticLink|url=https://www.instagram.com/p/CY_t7QhIWTD/|title=english title|italianTitle=italian title|tags=psicologia,governo,politica,lavoro}}
This MediaWiki template is used to create a semantic link, which is a link to a webpage with additional information (in a Semantic Mediawiki subobject) such as a title and tags.
The template has the following parts:
The first part, [{{{url}}} {{#if:{{{italianTitle|}}}|{{{italianTitle}}}|{{{title}}}}}], creates the link to the webpage specified by the "url" parameter. It also displays the title of the webpage, which can be specified by either the "title" or "italianTitle" parameter.
The #if function checks if the "italianTitle" parameter is passed, if it is, it will be used as the title, otherwise, the title parameter will be used.
The second part, {{{tags}}}, displays the tags associated with the webpage, which can be specified by the "tags" parameter.
The third part, {{#subobject:|url = {{{url}}}|title = {{{title}}}|italianTitle = {{{italianTitle}}}|tags={{{tags}}}|+sep=,}}, creates a subobject which is a container for additional information related to the link. Here it contains the url, title, italianTitle and tags parameters. The +sep=, is used to separate the tags with a comma when they are displayed.
The triple curly brackets, {{{ }}} , are used to define template parameters.
When the template is used on a page, the text inside the curly brackets is replaced by the value passed to the corresponding parameter.
For example, the {{{url}}} will be replaced by the value passed to the "url" parameter when the template is used, {{{title}}} will be replaced by the value passed to the "title" parameter and so on.

Related

Semantic Mediawiki: trying to query subobjects

I've page with a long list of subojects. The properties are correctly visibile. I've successfully queried that list from the same page and not I'm trying from another page:
I've magaed to point to the page, to filter for the tag, but it doesn't work as expected: it returns many tags (while it should return only one), it returns no title and 1 url.
{{#ask: [[-Has subobject::Tutti gli articoli di Marco Crepaldi]] [[Tags::femminicidi]]
|?tags
|?title
|?url
| mainlabel=-
}}

HTML-assigned 'id' Missing in DOM

Within the Moodle (v. 3.5.7) Atto editor (using both Chrome and Firefox) I've been trying to assign an ID to a particular row class, "span9". My ultimate objective is to assign this a unique ID and reference this element via jquery so as to append another element within it.
The ISSUE is that once I add an ID (id="checklist01") and click save, the ID simply does not appear in the DOM, and seems to not exist. When I re-enter the atto editor however, voila, there it is just sitting there. So it's NOT being removed completely... just not expressed somehow?
I have 2 screenshots linked below showing (1) the editor view, with the element and assigned ID highlighted, and (2) a screenshot of the DOM once the changes have been saved, with that same area highlighted, without the assigned ID.
Screenshots of ID Missing from DOM
Bootstrap ver. 4
So far I've tried switching the placement of the id in the atto editor (class coming first vs second after ); tried to add a "span" in front of the id (for some reason, I was desperate); and really just searched all over for someone who has encountered something similar.
I'm not sure how much help the html will provide, but here it is:
<div class="row-fluid colored">
<div class="iconbox span3">
h4>Your Completion Status (%)</h4>
</div>
<div id="checklist01" class="span9">
</div>
</div>
I found the reason for the removal of id attributes.
id attributes are removed because "Checklist" activity used safe HTML function of Moodle. If you want to access id attributes of description HTML follow below steps.
Go to mod\checklist\locallib.php file.
Then search formatted_intro() function (which is around line number 880).
In that function they used Moodle's format_text() function to return description text.
In that function, they have used 3 parameters.
string $text The text to be formatted.
int $format Identifier of the text format to be used
object/array $options text formatting options
Replace
$opts = array('trusted' => $CFG->enabletrusttext);
to
$opts = array('trusted' => $CFG->enabletrusttext,'allowid'=>true);
Then save your file and check. By following the above steps you can use id attributes.

Trying to programmatically set value of a list item's URL column

I'm trying to add a list item that contains a URL in its second column and I keep getting the following error:
Execution failed: The anchor tag supplied for the List Item was not
properly formed. (line 131, file "Code")
The lines in question (130 and 131) ares:
var values = [a,"< a href=\'DEBUG\'>details</a>",c,d,e,f,g,h];
var thislistitem = kbPage.addListItem(values);
I've tried passing the following for the second variable:
""
"<a href=\'DEBUG\'>details</a>"
DEBUG
http://www.something.com/
And I keep getting the same error. I expect that I should be passing a pair of values (a label and a url) somehow instead of a simple string, but I can find no reference anywhere to how to do that.
First of all there are three things:-
Coloumn in which want to enter the tag should be of URL type
Anchor tag should not have escape characters in between instead of
this "<a href=\'DEBUG\'>details</a>"
use "<a href='DEBUG'>details</a>"
Biggest mistake was space < a between < and a makes anchor tag invalid
Apply these things and it wont show any error

Putting HTML in a hidden form field in Django

I'm having a problem with a template: I'm trying to display a form for changing a value, in which the user enters the current value in a textarea and the old value is kept inside a hidden field for auditing purposes. This value is generally some HTML, and when I render the page this HTML in the hidden field seems to get partially rendered: the value attribute of my hidden field gets closed by the first quotation marks inside the entered HTML, and the rest of the HTML spews out onto my page. I've tried using the escape decorator but that hasn't changed anything.
Firstly, a better solution might be to keep the audit value in a separate model field defined with editable=False. You can still perform checks against the value in a form's clean method:
def clean(self):
cleaned_data = super(SomeForm, self).clean()
if instance.the_audit_field == cleaned_data['the_editable_field']:
...raise a validation error?
You can also modify the value of the audit field from within the model's save method.
Secondly, assuming you must do it the way you are now, let me address the non-escaped value in your template. I assume you're using something like the following:
<textarea value="{{ form.the_audit_field.value }}"></textarea>
You should instead use the following:
<textarea>{{ form.the_audit_field.value }}</textarea>
Note, the value goes inside the textarea, instead of in the value attribute of it.
An even better way to do it is to simply allow Django to render the field for you like the following:
{{ form.the_audit_field }}

E4X/AS3, get an array of text elements without looping

this is part of an XML file I retrieve using AS3 E4X:
<links>
<link>
<label>Versions</label>
<href>http://mylink1</href>
</link>
<link>
<label>Configurations</label>
<href>http://myLink2</href>
</link>
</links>
I want to retrieve the values of labels, so I write:
document.links.link.label.text();
This returns VersionsConfigurations. I need this as Array ([Versions, Configurations]) but I would like not to use a loop. Is there any other way?
Well, this is a "don't try this at home" solution, but here you are. :)
You can use E4X search expression to do whatever you want to nodes of an XMLList.
This works as follows: someXMLList.(expression), where expression is any AS3 code that can access each node's properties and methods with no need of qualifying their names. For instance, you could do the following:
yourXML.descendants("label").(trace("label text: ", text()));
Note that I'm using text() here with no access . operations. Actually this will return an new XMLList for all nodes, where expression evaluated to true. Since trace() returns void, the resulting list will be empty. Internally there is of course a loop through all nodes of XMLLIst that is created by calling descendants() (or using .. operator).
You can construct your array the same way.
var doc:XML =
<links>
<link>
<label>Versions</label>
<href>http://mylink1</href>
</link>
<link>
<label>Configurations</label>
<href>http://myLink2</href>
</link>
<link>
<label>A label
with
multiple
line
breaks</label>
<href>http://myLink3</href>
</link>
</links>;
trace(doc.descendants("label").text().toXMLString().split("\n"));
/* Trace output (incorrect):
Versions,Configurations,A label
,with
,multiple
,line
,breaks
*/
var list:Array = [];
doc.descendants("label").(list.push(text().toString()));
trace(list);
/* Trace output (correct):
Versions,Configurations,A label
with
multiple
line
breaks
*/
That may be useful when performing some complicated searches on an XMLList. However in your case I think you should instead use simple splitting of a string representation or a regular expression as Shane suggests.
An alternative technique could be to use a regular expression, although this particular example is dependent on your labels always starting with a capital and otherwise containing only lower case characters.
var regex:RegExp = /[A-Z][a-z]+/g;
var inString:String = "VersionsConfigurations";
var outArray:Array = inString.match(regex);
trace(outArray.length); // 2