Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Create a file with the name default_table.hbs by adding the following content in it.

    Code Block
    languagexml
    <h2 class="field-title">
        <a data-toggle="collapse" href="#collapse{{label}}" aria-expanded="false" class="collapsing-h2" >
            <i class="cu-btn-exp-col btn-collapsed">{{label}}</i>
        </a>
    </h2>
    <div class="collapse in" id="collapse{{label}}">}
        {{#eachField this.fields}}
                <div class="row padding-bottom-lg">
                    	<div class="col-sm-2 text-right">{{label}}</div>
    		{{#if_equal this.name.name "description"}}
    			<div class="col-sm-10">{{{value}}}</div>
    		{{else}}
    		<div class="col-sm-10">{{value}}</div>
    		{{/if_equal}}
                </div>
        {{/eachField}}
    </div>
    </div>
    Info

    The above code uses triple mustaches to unescape HTML in the value of the text field.

  2. Add the default_table.hbs file to the <G-REG_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/assets/restservice/themes/default/partials/ directory. 
  3. Add the following code block to the <G-REG_HOME>/repository/deployment/server/jaggeryapps/store/extensions/assets/restservice/asset.js file, to eliminate any <script> tags in HTML content in the G-Reg Store for security concerns.

    Code Block
    languagejs
    asset.renderer = function(ctx) {
        var decoratorApi = require('/modules/page-decorators.js').pageDecorators;
    
        return {
            pageDecorators: {
    	    sanitizedDescription: function(page) {
    		
    		if (page.assets && page.assets.attributes && page.assets.attributes.overview_description ){
             		var descriptionInfo=page.assets.attributes.overview_description;
    			var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
    				while (SCRIPT_REGEX.test(descriptionInfo)) {
        				descriptionInfo = descriptionInfo.replace(SCRIPT_REGEX, "");
    			
    				}
    		}
    
                }
            }
        };
    };
  4. Add the following code block to the <G-REG_HOME>/repository/deployment/server/jaggeryapps/publisher/extensions/assets/restservice/asset.js file, to eliminate any <script> tags in HTML content in the G-Reg Publisher for security concerns.

    Code Block
    languagejs
    asset.renderer = function(ctx) {
        var decoratorApi = require('/modules/page-decorators.js').pageDecorators;
    
        return {
            pageDecorators: {
    	    sanitizedDescription: function(page) {
    
    		if(page.assets.tables && page.assets.tables[0] && page.assets.tables[0].fields && page.assets.tables[0].fields.description && page.assets.tables[0].fields.description.value){
    			var descriptionInfo=page.assets.tables[0].fields.description.value;
    			var SCRIPT_REGEX = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi;
    				while (SCRIPT_REGEX.test(descriptionInfo)) {
        				descriptionInfo = descriptionInfo.replace(SCRIPT_REGEX, "");
    		
    		
    				}
    		
    		}
                }
            }
        };
    };
  5. Re-start the WSO2 G-Reg server.

  6. Log in to the G-Reg Publisher using the following URL and admin/admin credentials: https://<G-REG_HOST>:<G-REG_PORT>/publisher

  7. Anchor
    step6
    step6
    Create a new REST service using the G-Reg Publisher by adding the following HTML content for the text field of Description as shown below.
    adding HTMl in description field

    Code Block
    languagexml
    <p><strong><span style="font-size: medium;">HTML ImprovedCode</span></strong></p>
    <p>Improved HTML look with more features like:</p>
    <ol>
    <li><span style="background-color: #ffff00;">Code highlighting</span></li>
    <li>Auto-indenting</li>
    <li><span style="color: #ff0000;">Color Change</span></li>
    <li><span style="text-decoration: underline;">Underline</span></li>
    <li>Line Number</li>
    </ol>
    <p style="text-align: left;"> </p>

Viewing the content added using HTML 

Follow the steps below to view the Description field updated for the REST Service which you created in step 7 above.

  1. Log in to the G-Reg Publisher using the following URL and admin/admin credentials: https://<G-REG_HOST>:<G-REG_PORT>/publisher
  2. Select REST Services from the main menu of G-Reg Publisher as shown below.
    select REST Services from the main menu
  3. Select the corresponding asset, which you created above as shown below.
    select the REST Service
    You view the content you added for the Description filed using HTML as shown below.