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, "");
    		
    		
    				}
    		
    		}
                }
            }
        };
    };
    Note

    If you want to add the content to a field that appears for REST Services in WSO2 G-Reg Store also, create a file with the name asset-attributes.hbs by adding the following content, and add that file to the <G-REG_HOME>/repository/deployment/server/jaggeryapps/store/extensions/assets/restservice/themes/store/partials/ directory.

    Code Block
    languagejs
    <div class="table-responsive">
        <div class="col-lg-12">
            <h4>Overview</h4><hr>
            <div class="col-lg-12 table table-striped table-hover divrow">
                <div class="col-lg-2">Name</div>
                {{#if name}}
                    <div class="col-lg-10">{{name}}</div>
                {{else}}
                    <div class="col-lg-10">{{assetName}}</div>
                {{/if}}
            </div>
    
            <div class="col-lg-12 divrow">
                <div class="col-lg-2">Version</div>
                <div class="col-lg-10">{{version}}</div>
            </div>
    	<div class="col-lg-12 divrow">
    	    <div class="col-lg-2">{{t "Description"}}</div>
    	    <div class="col-lg-10">{{{this.attributes.overview_description}}}</div>
    	</div>
        </div>
        {{#if lifecycle}}
            <div class="col-lg-12">
                <h4>Lifecycle</h4><hr>
                <div class="col-lg-12 table table-striped table-hover divrow">
                    <div class="col-lg-2">Name :</div>
    
                    <div class="col-lg-10">{{lifecycle}}</div>
                </div>
    
                <div class="col-lg-12 divrow">
                    <div class="col-lg-2">State :</div>
                    <div class="col-lg-10">{{lifecycleState}}</div>
                </div>
            </div>
        {{/if}}
        {{#if isDependentsPresent}}
            <div class="col-lg-12">
                <h4>Associations</h4><hr>
                <div class="col-lg-12 table table-striped table-hover divrow">
                    {{#each dependencies}}
                        <div class="col-lg-2 ">Dependencies :</div>
                        <div class="col-lg-10"><a href="../../../assets/{{this.associationType}}/details/{{this.associationUUID}}">{{this.associationName}}</a></div>
                    {{/each}}
                </div>
    
                <div class="col-lg-12 divrow">
                    {{#each dependents}}
                        <div class="col-lg-2">Dependents :</div>
                        <div class="col-lg-10"><a href="../../../assets/{{this.associationType}}/details/{{this.associationUUID}}">{{this.associationName}}</a></div>
                    {{/each}}
                </div>
            </div>
        {{/if}}
    
    </div>
  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>

...