From version < 71.1 >
edited by Vivek Iyer
on 2018/08/03 17:43
To version < 72.1 >
edited by Vivek Iyer
on 2018/08/03 17:43
< >
Change comment: There is no comment for this version

Summary

Details

ExtensionCode.ExtensionClass[0]
Description
... ... @@ -31,9 +31,10 @@
31 31  
32 32  == Categories ==
33 33  
34 -There are two categories in the XML Toolbox, the default categories like logic, loops, variables, text, colour, lists etc which are there by default in the Blockly toolbox developed by Google, and the custom categories which have been added to meet XWiki-specific requirements and use cases, like macros, queries, XWiki Bindings etc
35 35  
35 +There are two categories in the XML Toolbox, the default categories like logic, loops, variables, text, colour, lists etc which are there by default in the Blockly toolbox developed by Google, and the custom categories which have been added to meet XWiki-specific requirements and use cases, like queries, XWiki Bindings etc
36 36  
37 +
37 37  === Default Categories ===
38 38  
39 39  The [[blockly documentation>>https://github.com/google/blockly/wiki]] contains the documentation for the default categories such as logic (if-else), loops, variables, text, colour, lists etc
... ... @@ -43,6 +43,34 @@
43 43  
44 44  The following custom categories have been introduced:
45 45  
47 +
48 +==== XWiki Bindings ====
49 +
50 +{{image reference="XWiki Bindings.png" |alt="XWiki Script Bindings" width="150" height="168"}}{{/image}}
51 +
52 +===== Text Block =====
53 +
54 +* A simple text input block, used to generate attribute/object names
55 +
56 +===== XWiki Bindings Block =====
57 +
58 +* Defines the common XWiki Bindings, as defined [[here>>https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Scripting/#HBindings]]
59 +
60 +===== XWiki Bindings Attribute Block =====
61 +
62 +* Used to access the attributes of the XWiki Bindings
63 +* Takes the XWiki binding as one input and the attribute name as the other text input
64 +* For the static XWiki Bindings, the block defined above can be input.
65 +* For dynamic XWiki Bindings, a variable can be created with the desired name, and that can become the input.
66 +
67 +===== XWiki Bindings Method Block =====
68 +
69 +* Used to call the methods of the XWiki Bindings
70 +* Takes the XWiki binding as one input and the method name as the other text input
71 +* The number of arguments to the method call is variable, and can be added/removed by clicking on the cog icon in the top left corner
72 +* For the static XWiki Bindings, the block defined above can be input.
73 +* For dynamic XWiki Bindings, a variable can be created with the desired name, and that can become the input.
74 +
46 46  ==== Queries ====
47 47  
48 48  {{image reference="Queries.png" |alt="The XWQL Queries category" width="150" height="395"}}{{/image}}
... ... @@ -91,8 +91,31 @@
91 91  * This block takes as input two boolean returning blocks, and returns the "AND" or "OR" of these expressions.
92 92  * By default the boolean expression in input is false.
93 93  * It is also possible to chain "AND"/"OR" expressions by giving another AND/OR block as input to the first block.
123 +
124 +===== Comparison Operators Block =====
125 +
94 94  
95 95  
128 +* This block takes as input two expressions, and returns an expression with the two values joined by an operator.
129 +* The operators can be chosen from the dropdown menu and are one among "=", "≠", ">", "<", "≥", "≤" etc
130 +* It is possible to chain these expressions too, similar to the AND/OR block.
131 +
132 +===== Like Block =====
133 +
134 +
135 +
136 +* This block provides the LIKE keyword
137 +* Selecting the checkbox on either side adds a "%" on either side to the text input given in the textbook
138 +* This is given as input to the AND/OR block
139 +
140 +===== Order by Block =====
141 +
142 +
143 +
144 +* This block provides the Order by keyword
145 +* The ascending/descending order can be chosen from the menu and it takes the XWiki property to be ordered as input.
146 +* Again this is given as input to the AND/OR block
147 +
96 96  ===== Not Block =====
97 97  
98 98  * The NOT operator is used to negate the predicate that follows it.
cogAdds a new document template based on Google Blockly
TypeXAR
CategoryApplication
Developed by

Vivek Iyer

Active Installs4
Rating
Rate!
0 Votes
LicenseGNU Lesser General Public License 2.1
Bundled With

XWiki Standard

Installable with the Extension Manager

Description

This extension adds the Google Blockly Template to XWiki, to make programming easier for users who have little/no previous experience of programming, by allowing the creation of Blockly templated documents. Currently, this template provides support for combining the blocks from the default toolbox provided by Google, viewing the source code for the same, editing a document using these blocks and saving it.

Usage

To create a document using the Blockly template, please follow the steps given below:

  1. Make sure you're logged in
  2. Click on create page at the top right corner, and choose the "Blockly" template in the create page document.
    CreateBlocklyTemplateDoc.png
    Selecting Blockly editor to edit the page
  3. This should take you to the Blockly template page. Drag and drop the blocks from the toolbox onto the adjacent div and combine them like puzzle pieces, as desired. For example:
    For example:

BlocksView.png
Combining blocks appropriately

  1. To delete any of the blocks, drag and drop the blocks into the bin.
  2. To view the source code for the blocks generated in the figure, click on the Source tab.
    SourceView.png
    Source Code View
  3. Save the code using either the "Save and View", or the "Save and Continue" buttons.
  4. If you want to view the code you generated and/or execute it, go to the View Page. It looks like this:
    GenCodeView.png
    Viewing the Generated Code
  5. To run the code, click on "Run Code". Now after the code has been run, to view the original code again, click on "View Code".
    ExecCode.png
    The code executed
  6. In case you want to edit the page, click on the edit button once again and all the Blockly blocks are loaded as they should be emoticon_smile

Categories

There are two categories in the XML Toolbox, the default categories like logic, loops, variables, text, colour, lists etc which are there by default in the Blockly toolbox developed by Google, and the custom categories which have been added to meet XWiki-specific requirements and use cases, like macros, queries, XWiki Bindings etc

There are two categories in the XML Toolbox, the default categories like logic, loops, variables, text, colour, lists etc which are there by default in the Blockly toolbox developed by Google, and the custom categories which have been added to meet XWiki-specific requirements and use cases, like queries, XWiki Bindings etc

Default Categories

The blockly documentation contains the documentation for the default categories such as logic (if-else), loops, variables, text, colour, lists etc

Custom Categories

The following custom categories have been introduced:

XWiki Bindings

XWiki Bindings.png

Text Block
  • A simple text input block, used to generate attribute/object names
XWiki Bindings Block
  • Defines the common XWiki Bindings, as defined here
XWiki Bindings Attribute Block
  • Used to access the attributes of the XWiki Bindings
  • Takes the XWiki binding as one input and the attribute name as the other text input
  • For the static XWiki Bindings, the block defined above can be input.
  • For dynamic XWiki Bindings, a variable can be created with the desired name, and that can become the input. 
XWiki Bindings Method Block
  • Used to call the methods of the XWiki Bindings
  • Takes the XWiki binding as one input and the method name as the other text input
  • The number of arguments to the method call is variable, and can be added/removed by clicking on the cog icon in the top left corner
  • For the static XWiki Bindings, the block defined above can be input.
  • For dynamic XWiki Bindings, a variable can be created with the desired name, and that can become the input. 

Queries

Queries.png
This category contains the following blocks:

Execute Block
  • Takes the query string/variable as input
  • Outputs $services.query.xwql(query).execute()
Select, From, Where Block
  • This is the main block that generates the query, and it has SELECT, FROM and WHERE clauses each of which takes arguments as input. These arguments can be constructed using the other blocks on this category.
  • The "SELECT" input block takes a list of attributes while "FROM" takes a list of objects to be selected "from" as input.
  • Where takes a boolean expression as input, which can be constructed using the AND/OR blocks and the comparison blocks, described below.
    SFWBlock.png
Arguments Block
  • Takes variable number of arguments as input, and the arguments can be added/removed by clicking the cog on the top left corner
  • Returns comma separated list of the arguments provided, which can be input to either the "SELECT" or the "FROM" input blocks.
      
Get XObject Block
  • Returns the specified XObject in the current document 
  • The input is the XWiki Class Name (for example to get get the XObject of class XWiki.XWikiUsers, the inputs in the two text fields will be XWiki and XWikiUsers. The code output for this example would be doc.object(XWiki.XWikiUsers)
    GetClass.png
Get Object Property Block
  • Returns the properties/attributes of an object
  • The first input field takes the object as input, and the second input field is a text input which takes the attribute name as input.
  • For example, to get attribute space.name, we do:
    GetAttrib.png
As Block
  • This provides the AS keyword
  • It takes the value to be aliased as one input, and the alias itself as another text input. The checkbox is used to indicate whether the word "as" itself should be added or not, since specifically mentioning "as" is optional in XWQL.
  • For example, keeping the checkbox checked and aliasing XWikiSpace as space, the code generated would be XWikiSpace as space but on unchecking it, the code generated is simply XWikiSpace space
AND/OR Block
  • This block takes as input two boolean returning blocks, and returns the "AND" or "OR" of these expressions.
  • By default the boolean expression in input is false.
  • It is also possible to chain "AND"/"OR" expressions by giving another AND/OR block as input to the first block.
     
  • It is also possible to chain "AND"/"OR" expressions by giving another AND/OR block as input to the first block.
Comparison Operators Block

 

  • This block takes as input two expressions, and returns an expression with the two values joined by an operator.
  • The operators can be chosen from the dropdown menu and are one among "=", "≠", ">", "<", "≥", "≤" etc
  • It is possible to chain these expressions too, similar to the AND/OR block.
Not Block
Like Block

 

  • This block provides the LIKE keyword
  • Selecting the checkbox on either side adds a "%" on either side to the text input given in the textbook
  • This is given as input to the AND/OR block  
Order by Block

 

  • This block provides the Order by keyword
  • The ascending/descending order can be chosen from the menu and it takes the XWiki property to be ordered as input.
  • Again this is given as input to the AND/OR block  
Not Block
  • The NOT operator is used to negate the predicate that follows it. 
Distinct Block
  • Returns only distinct, not duplicate, results
  • Takes an object attribute as input 

Features

  • A toolbox containing the default categories for loops, logic statements, variables, macros, math, text etc and the customly added categories for XWiki Script bindings and XWQL queries. (Check Categories section given above for more detail)
    BlocklyToolbox.png
    The Blockly toolbox
  • A bin for deleting unnecessary blocks, and features for creating duplicate blocks, adding comments etc by right-clicking on a block
    RightClickBlocklyMenu.png
    Right clicking on Blockly blocks generates this menu
  • Converting this generated code into Velocity and running it as well
  • Displaying the generated code in the textarea, wherein the code gets inserted at cursor position
  • Saving the code to the page

(For screenshots and more information on how to use these features, please check the Usage section given above emoticon_smile)

Future

Refer the Blockly design page for further details.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Dependencies

Dependencies for this extension (org.xwiki.contrib:application-blockly-ui 0.9):

Get Connected