I use Semantic Mediawiki and Semantic Forms.
I made a form that uses subobjects. So for showing on Mediawiki page the text that user has written in my form - I use #ask query and wiki template. My ask code is like this:
{{#ask: [[-Has subobject::{{FULLPAGENAME}}]]
|?MyProperty1
|?MyProperty2
|format=template
|template=MyTemplateLayout
|introtemplate=MyTemplateLayoutHeader
|outrotemplate=MyTemplateLayoutFooter
|named args=yes
}}
It works when user's text in the form is small. But if text has enters, bullets or <br> tag inside it - query result is empty:
Is it possible to configure or hide the long text in my forms to make working query result? How can I do it?
Just in case - my template code is:
{{#if:{{{?MyProperty1|}}} {{{?MyProperty2|}}}|
{{!}}- style="background-color: WhiteSmoke;"
{{!}}{{{?MyProperty1|}}}{{!}}{{!}}{{{?MyProperty2|}}}
{{!}}-
}}
And my Form code is like:
{{{for template|MySubobject|multiple|add button text=Добавить|embed in field=Test[TestField]}}}
{{{field|MyProperty1|input type=textarea|cols=90|rows=1|autogrow=true}}}||{{{field|MyProperty2|input type=textarea|cols=90|rows=1|autogrow=true}}}
...
Please ensure that your property has type Text ( create page Property:MyProperty with contents [[has type::Text]] ).
Related
I am using semantic mediawiki to store and describe information about scientific papers. In this context I would like to build a citation template that links to the page where the paper is described.
Every Paper has an identifier which is a combination of first author and year with the property like this: [[Has citekey:someauthor2019]]. I use a template to cite this paper as {{Cite | someauthor2019}} and combine the Cite template with a format template to render it as a link to the page with the name of the citekey.
The problem is that when I do it with the templates below, it will actually display the wikitext:
[[Name of the page | someauthor2019 ]]
instead of evaluating it to appear as the named link:
someauthor2019
This is the semantic-mediawiki ask query to get the paper information:
Template:Cite
{{#ask: [[Has citekey::{{{1}}}]]
|?Has citekey
|format=template
|template=Cite Text
}}
This is the format template to deal with the results of the query:
Template:Cite_Text
[[{{{1}}} | {{{2}}}]]
How can I get the avaluated result of a named link to be displayed instead of the wikitext?
Thank you in advance for any help!
Try to use
|link=none
this will pass {{{1}}} result as raw text to your template
You request becomes :
{{#ask: [[Has citekey::{{{1}}}]]
|?Has citekey
|format=template
|template=Cite Text
|link=none
}}
Source :
https://www.semantic-mediawiki.org/wiki/Help:Inline_queries#Standard_parameters_for_inline_queries
I am trying to find in alley files using a regex search in WebStorm. I have 2 scenarios.
Scenario 1: text inside html tag
<p>testing</p>
Scenario 2: dynamic text inside {{ and }} inside html text
<p>{{testing}}<p>
I was able to find text between html tags using below regex for Scenario 1
>(.*?)</
I am trying to find only places with scenario 1 and not with scenario 2. I mean I want to see all the hard coded text between html tags and not any text between {{ and }}. Any suggestion or pointer?
Have you tried using regexr.com?
Edit
How is this:
>(\w+)</
I have a string like this:
Plain text with newlines.
But it also has some html.
<ul>
<li>first</li>
<li>second</li>
</ul>
I'd like the lineabreaks filter to output an HTML like this:
<p>Plain text with newlines.<br/>
But it also has some html.</p>
<ul>
<li>first</li>
<li>second</li>
</ul>
But what I get is:
<p>Plain text with newlines.<br/>
But it also has some html.</p>
<ul><br />
<li>first</li><br />
<li>second</li><br />
</ul>
Any idea to prevent HTML parts to be line-breaked, but still allow the filter to do its job on plain text parts?
EDIT - #Shang Wang: The real-world usage for this filter is a backend for writers who are familiar with HTML and prefer not to use a rich text editor, but would still like to avoid typing "<br />" or "<p>" everytime they need to go to a newline.
Basically, what I'm trying to do is to emulate Drupal's "Filtered HTML" input filter, which is meant for editors who need a way to quickly write simple articles without using a WYSIWYG editor, but with the possibility to add more advanced HTML tags (like , , etc..) here and there.
Hope this helps to understand my goal, and sorry for my english.
EDIT 2 - #karison: I don't have a particular approach, yet. My current code is:
{{ myText | bleach | linebreaks }}
I'd like to avoid to write from scratch a custom filter just for this, so I don't have any code to show. As it's something that I've seen in Drupal and other CMS, I was hoping that there was some way to do it with the current linebreaks filter.
No I don't think it's possible and it doesn't make much sense. You could have new lines in your html section as well:
<p>This is a
multiple line text.
</p>
but they won't be shown as multiple lines when the browser is rendering them. Then what is the template filter suppose to do? I think the best option for you is to separate the text yourself in your views.
Edit:
First off I'm not aware of any such django template filter exists because your situation is too specific to make it a public template filter, also the requirement is complex and require a parser to distinguish between html and plain text.
Secondly, multi-line text is not rendered by inserting <br/> for each new line(w3school's doc). Instead you use the tag <pre></pre> to wrap your paragraph. In theory, for each block of plain text you could wrap <pre> around it, then the new lines will be shown "as is".
i used tinymce to allow people to write content. But now i wan't them to edit their own content, i need to use tinymce again.
My problem is in my database, this content is composed of html tags, and when i try to load the text in my tinymce textarea (in edit view), i've got the raw content eg <p> Hello my name is <em>John</em> [...] </p> . But when they written this content, it was with "wysiwyg".
I want to convert this raw html to wysiwig.
here a screenshot of the raw html
and i want it to be like this when they click on "edit my content" button :
I use this:
echo <textarea name="icerik" id="editor1" rows="10" cols="80">'.htmlentities($satir->icerik).'</textarea>;
I use "htmlentities" method in php to convert html code to wysiwyg. When you write that converted text between and , you can get what you want.
Assuming you're using PHP of course. If not, try to search like for example "htmlentities in asp.net" or wait for another answers.
tinyMCE.activeEditor.setContent('<span>html data from your database</span>');
Use this:
strip_tags(stripslashes('row html content'))
I´m really bad at programming, and I´m trying to do a web aplication using html and jsp pages, the application have to allows the users to post things, and well that is the problem, because I can´t separate text and links from the textarea.
There is the method to post.
<div id ="post">
<form method="post" action="Validaciones.jsp" >
<textarea name="comentario" rows="4" cols="20" maxlength="140" id="coment" >
</textarea>
<button name="publicar" value="publicar">Publicar</button>
</form>
</div>
But so, when I do:
String texto = request.getParameter("comentario");
It return the parameter as a String, so if a put, "Hello visit my page: www.ducks.com", there is a way to know what is text and what is the link?
Because the aplication have to show the links as links, with the (a) tag.
Thanks for the help.
Dont use plain textarea.You need to use editors like CKEditor,TinyMce(to name a few).
These editors help to maintain the text formatting and save it into the database.So when you view this on another page you will be able to see whatever you had written earlier in the editor.Hence these editors are called WYSIWYG (What-You-See-Is-What-You-Get)
So use these editors in your page.
Use regular expressions
Pattern p = Pattern.compile("^(http|https|ftp)\://[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\+&%\$#\=~])*[^\.\,\)\(\s]$", Pattern.CASE_INSENSITIVE);
String toMatch = "this is a URL http://google.com";
Matcher m = p.matcher(toMatch);
With the url , use substring for the string.