CKEditor: create a new object from a parent object - object

A question about creating a new object within an object.
Say that you edit a query created with CKEditor, and that query is stored as an object. In that query, you identify a part of the text, and from that part, you want to create a new object which is supposed to live within its parent object, but also be independent.
Example:
query obj starts here:
text ...
more text ... (this represents the new object that I want to create)
end text...
query obj ends here.
example html when you edit an existing query created with CKeditor:
<div id="wrapper">
<div id="para">
<p>This represents a citation that should become an object.<p>
</div>
</div> <-- end #wrapper -->
The newly created object remains in the old object (old object is an article, say), but the new object receives its own tags and link.
Can this be done; if so, how? :-)

Related

How to make a TiddlyWiki table of contents (toc) with differnt colors

I use
<div class="tc-table-of-contents">
<<toc "Inhalt">>
</div>
where every tiddler tagged with Inhalt is listed in toc. This works fine.
But I have an additional tag named Fahrt. Is it possible to change the color in the toc of this entries? The result should look like this:
Only tag Inhalt --> normal blue color
tag Inhalt + tag Fahrt --> perhaps a lighter blue oder different color
This isn't possible with the default toc macros, but we can write a new macro based on the built-in toc macro to do this without too much trouble. We'll make a version of the macro, template-toc, that uses a template to display each element in the table of contents – this way, we'll be able to reuse our work to format TOC elements in a totally arbitrary way. (Fuller explanation of templates. NB: I wrote this.)
We first start by copying the macros toc and toc-body from $:/core/macros/toc and pasting them into a new tiddler $:/template-toc-macros (you can call this tiddler anything you want) with the tag $:/tags/Macro (this will cause the macros in it to be available in any tiddler in the wiki).
Then we rename toc-body and all references to template-toc-body, likewise toc to template-toc. We add a parameter template as the second parameter of both of these macros, and adjust the bodies of both so that they transclude the <<__template__>> parameter as a tiddler rather than looking into the caption and title fields for a title and creating a link with this as the text. That makes the body of this tiddler look like this:
\define template-toc-body(tag,template,sort:"",itemClassFilter,exclude,path)
\whitespace trim
<ol class="tc-toc">
<$list filter="""[all[shadows+tiddlers]tag<__tag__>!has[draft.of]$sort$] -[<__tag__>] -[enlist<__exclude__>]""">
<$let item=<<currentTiddler>> path={{{ [<__path__>addsuffix[/]addsuffix<__tag__>] }}}>
<$set name="excluded" filter="""[enlist<__exclude__>] [<__tag__>]""">
<$set name="toc-item-class" filter=<<__itemClassFilter__>> emptyValue="toc-item-selected" value="toc-item">
<li class=<<toc-item-class>>>
<$transclude tiddler=<<__template__>>/>
<$macrocall $name="template-toc-body" tag=<<item>> template=<<__template__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> exclude=<<excluded>> path=<<path>>/>
</li>
</$set>
</$set>
</$let>
</$list>
</ol>
\end
\define template-toc(tag,template,sort:"",itemClassFilter:"")
<$macrocall $name="template-toc-body" tag=<<__tag__>> template=<<__template__>> sort=<<__sort__>> itemClassFilter=<<__itemClassFilter__>> />
\end
Now here's how we use this: we create a template tiddler which, given that the variable <<currentTiddler>> is set to a particular tiddler we want to include in the TOC, renders the HTML/wikitext we want to include in the table of contents. In this example, we'll call this tiddler MyTemplate, but you'll probably want to use something more descriptive. In your case, the text will look something like:
<$link to=<<currentTiddler>>>
<$list filter="[all[current]tag[Fahrt]]" emptyMessage="""<$view field='caption'><$view field='title' /></$view>""">
<span style="color: red;"><$view field='caption'><$view field='title' /></$view></span>
</$list>
</$link>
That is, if the filter [all[current]tag[Fahrt]] has any output, i.e., the currentTiddler is tagged Fahrt, then fill in the body of the $list widget (creating a span with a color: red; CSS property), containing the caption field if it exists on the tiddler, or the title field otherwise. If it's not tagged Fahrt, then fill in the contents of emptyMessage, which does the same thing but without the color. In either case, create a link going to currentTiddler containing that content.
Lastly, wherever you want to show the table of contents, call the template-toc macro instead of the toc macro, and pass it the template you just created as a second argument:
<div class="tc-table-of-contents">
<<template-toc "Inhalt" MyTemplate>>
</div>
Result:

How etherpad recognizes author color?

So I have googled it and i didn't find any solution there so I am posting my question in here.
So when you write in etherpad, it creates markup which looks like this:
<div id="magicdomid17" class="ace-line">
<span class="author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z">
Author1.
</span>
<span class="author-a-1z74zz83zuz82z2z67zz815zsz89zz70zz65z8z69zz87z9">
Author2.
</span>
</div>
Now It will output this:
Author1.Author2.
Having different background colors for Author1. and Author2. texts depending upon what writers chose when they started using etherpad.
My question is how etherpad process the data to put background color on specific text.
I know it has something to do with classes given to span as:
author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z for first author
and
author-a-1z74zz83zuz82z2z67zz81zsz89zz750zz65z8z659zz87z9for second author.
Can anyone explain how the background-color is being put for these texts depending upon these classes name? and which file is responsible for that?
Thanks in advance
So as most of the etherpad questions, no one answered this question either. I got the solution if anyone got same problem for deciding text color depending upon class name.
All you need is define a object variable in your front end js file where you are using the etherpad. In this var we will take author class name as key and its respective color as value.
var window.authClassColorObj = {};
Now go into ace2_inner.js file and find function setAuthorStyle() , add these lines in that function after var authorSelector = getAuthorColorClassSelector(getAuthorClassName(author)); line:
parent.parent.parent.window.authorClassColorObj[getAuthorClassName(author)] = info.bgcolor;
Now i am accessing my front end object var by three layer in, so i am using parent.parent.parent. , it can be different for you depending upon you file structure.
Idea is that this is the place where you can populate your object with proper values.
and then you can access your object from front end, for example for my case, it will out put this:
console.log(window.authClassColorObj);
Output:
object{
author-a-w3z75zz84z95z83zpz77zz89zz66zz79zxz90zz66zcz76z:"#f50966"
author-a-1z74zz83zuz82z2z67zz815zsz89zz70zz65z8z69zz87z9:"#20a251"
}
This info can be used further for any changes you want to make in pad html code.

Issue while saving the dynamic field values in the preferences

I have already posted one question on the same issue. But I'm not able to solve my issue and not able to move forward in my task.
I have created a editable portlet where in the configuration page I am showing he dynamic questions which are fetching form the database. So for the same reason I am iterating my array list and creating the input fields dynamically as follows,
Iterator<String> itr = al.iterator();
while(itr.hasNext())
{
String columnVal = itr.next();
columnVal = columnVal.trim().toLowerCase();
%>
<aui:input name="<%=columnVal%>" type="checkbox" />
<%
}
With the above code the fields are creating dynamically with proper labels and seems to be fine.
When I try to save these dynamic field values in the preference I changed my input statement syntax to the proper way by adding the prefix as "preferences--" and suffix as "--" as shown below,
<aui:input name="preferences--<%=columnVal%>--" type="checkbox" />
I don't know what syntax is wrong in the above statement. But I am not able to see the label names in UI. instead of showing the proper label names for all labels it is showing <%=columnVal%> on UI.
I am using default configuration action class in my liferay-portlet.xml as mentioned below,
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>
Can any one please correct my syntax and help me to save my dynamic field values in the preferences.
From reference link's comment section:
According to JSP 2.1 Specification multiple expressions and mixing of
expressions and string constants are not permitted.
So you have to use below code in your case:
<aui:input name='<%="preferences--"+columnVal+"--"%>' type="checkbox" />

Add Body Part to Custom Widget - Placement

This time I'm struggling with my custom widget for Orchard.
It's a simple content part with two fields:
- Background Color
- Size
I want to be able to add HTML content to this widget; so I added the Body Part. This part must be displayed within my widget. The result should be something like this:
<div class="size-small bg-color-red"> BODY PART HTML CONTENT </div>
But unfortunately, the Body Part is always displayed before or after my widget.
<Placement>
<Place Parts_ContentTile="Content"/>
<Place Parts_ContentTile_Edit="Content:7.5"/>
</Placement>
Not so nice 'solution':
A way to resolve this is to remove the body part and replace it with a simple text field. This text field is rendered at the desired position. But then the TinyMCE Editor is not available.
Update after comment from Ivan:
I tried to change both (Content Type and Content Part (separate)) but unfortunately, both times, the TextField content is displayed after the widget. Should that be fixed in the Placement.info?
Another option is to add a String field to my Widget Model. But then it is not possible to show the TinyMCE editor. Am I right?
So I've got the feeling that my expectations about widgets, content parts and placements are incorrect. Hopefully somebody here can point me in the right direction.
When using TextField, you can use TinyMCE by specifying HTML flavor in the settings of the field.
To do that you can go to Content → (Content Types or Content Parts depending on which you are trying to change) → Select your ContentType or ContentPart → Expand the definition of the TextField you're using → Select HTML from the drop down menu next to Flavor → Click on Save button.
This post on SO from Mark Z was really helpfull to me!
I added a String property to my Model and added a new Database Migration:
public int UpdateFrom3()
{
// Adds a new Content column
SchemaBuilder.AlterTable("ContentTileRecord", table => table.AddColumn("Content", DbType.String));
return 4;
}
After that I added the field to the Editor Part View:
#Script.Require("OrchardTinyMce")
<div class="editor-label">
#Html.LabelFor(model => model.Content)
</div>
<div class="editor-field">
#Html.TextAreaFor(model => model.Content, new { #class = "html tinymce" })
</div>
The Content Property is now displayed as a TextArea. Because of the classes 'html and tinymce' the TinyMCE editor is instantiated. (Don't forget the Script.Require call)
Because of the fact that the Content property contains HTML, it is required to use the #Html.Raw helper to display the value of this property.
#Html.Raw(Model.Content)

Expression Engine - Pass loop variable into embeded template

have some trouble with Expression Engine variable passing in templates.
There is some piece of code:
// query:
{exp:channel:entries
channel="static"
}
// repeating field in a loop
{content_matrix}
<div>
{text_cell}
</div>
{image}
{/content_matrix}
//
{/exp:channel:entries}
I want to move content_matrix field with big inner HTML (example is shorter) sctructure into separate embed template for reusage in other templates.
Tried to build such embed but it doesnt work:
{embed="incl/content_matrix" matrix="{content_matrix}"}
And body of smaller template:
{embed:matrix}
<div>
{text_cell}
</div>
{image}
{/embed:matrix}
In this way it works if you passing single element, like ID, but not for mupltiple element.
Maybe it needs to pass entire entry.
How it can be done?
Thanks.
Have you considered using the Stash add-on?
I imagine you can stash the matrix content dividing between different parts of your html with some kind of separator, then in the embedded template wrap a search/replace for the separators with the proper html around the grabbed stash.
It might be less of a pain to write a quick, custom plugin, though.
Embed variables pass parsed output, not tags. So in your example:
{embed="incl/content_matrix" matrix="{content_matrix}"}
What you're actually passing in the matrix parameter is the full HTML table output of the data in that particular entry (since Matrix fields output a table when used as a single tag).
I think what you actually want to use to prevent repeating yourself is a Snippet. So just make a snippet containing:
{content_matrix}
<div>
{text_cell}
</div>
{image}
{/content_matrix}
And save it as, say, matrix_loop. Then include it inside your Channel Entries loop like so:
{matrix_loop}

Resources