1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 08:12:27 +00:00

Fixed Playground

This commit is contained in:
J. Fernando Sánchez 2016-02-22 15:09:51 +01:00
parent b8339e397b
commit a50f026701
3 changed files with 93 additions and 104 deletions

View File

@ -107,7 +107,7 @@ class Senpy(object):
candidates = self.filter_plugins(is_activated=True)
if len(candidates) > 0:
candidate = list(candidates.values())[0]
logger.debug("Default: {}".format(candidate))
logger.debug("Default: {}".format(candidate.name))
return candidate
else:
return None

View File

@ -1,6 +1,7 @@
var ONYX = "http://www.gsi.dit.upm.es/ontologies/onyx/ns#";
var RDF_TYPE = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
var plugins_params={};
function replaceURLWithHTMLLinks(text) {
console.log('Text: ' + text);
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
@ -15,6 +16,15 @@ function encodeHTML(text) {
.replace(/'/g, ''');
};
function hashchanged(){
var hash = location.hash
, hashPieces = hash.split('?');
if( hashPieces[0].length > 0 ){
activeTab = $('[href=' + hashPieces[0] + ']');
activeTab && activeTab.tab('show');
}
}
$(document).ready(function() {
var response = JSON.parse($.ajax({type: "GET", url: "/api/plugins/" , async: false}).responseText);
var defaultPlugin= JSON.parse($.ajax({type: "GET", url: "/api/plugins/default" , async: false}).responseText);
@ -55,15 +65,18 @@ $(document).ready(function() {
}
document.getElementById('plugins').innerHTML = html;
change_params();
$(window).on('hashchange', hashchanged);
hashchanged();
$('.tooltip-form').tooltip();
});
function change_params(){
var plugin = document.getElementById("plugins").options[document.getElementById("plugins").selectedIndex].value;
html=""
for (param in plugins_params[plugin]){
if (param || plugins_params[plugin][param].length > 1){
html=""
html+= "<label> Parameter "+param+"</label>"
html+= "<select id=\""+param+"\" name=\""+param+"\">"
for (option in plugins_params[plugin][param]){
@ -93,3 +106,5 @@ function load_JSON(){
document.getElementById("input_request").innerHTML = "<label>"+url+"</label>"
}

View File

@ -27,8 +27,8 @@
</div>
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a class="active" href="#about" role="tab" data-toggle="tab">About</a></li>
<li role="presentation"><a class="active" href="#test" role="tab" data-toggle="tab">Test it</a></li>
<li role="presentation" class="active"><a class="active" href="#about">About</a></li>
<li role="presentation"><a class="active" href="#test">Test it</a></li>
</ul>
<div class="tab-content">
@ -36,11 +36,8 @@
<div class="row">
<div class="col-lg-6 ">
<div class="well">
<h2>Test our services</h2>
<h2>Test Senpy</h2>
<div>
<p>EUROSENTIMENT provides services and resources for Sentiment Analysis in several languages. There are several utilities, code snippets and instructions on how to make use of the platform publicly available. However, all of them require the installation of a third party tool or the use of a programming language to consume the API.</p>
<p>The EUROSENTIMENT Playground solves this problem by providing an easy-to-use web interface to make API calls.</p>
<p>Read our simple instructions and start using EUROSENTIMENT today! Once you're ready, head to the right section:</p>
<p class="text-center">
<a class="btn btn-lg btn-primary" href="#test" role="button">Test it »</a>
</p>
@ -51,28 +48,7 @@
</div>
<div class="col-lg-6 ">
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-sign-in"></i> Sign up in the <a href="http://portal.eurosentiment.eu">EUROSENTIMENT portal</a></div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-pencil-square-o"></i> Get your access token.</div>
<div class="panel-body">
<p>Your credentials will allow you to access any service available to you.</p>
<p>For convenience, some services might be publicly available, under heavy restrictions.</p>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading"> <i class="fa fa-sliders"></i> Add the parameters you need for the service.</div>
<div class="panel-body">
<ol>
<li>Set the endpoint</li>
<li>Choose the HTTP action (GET/POST)</li>
<li>Set the headers (for authentication)</li>
<li>Set the necessary parameters (e.g. input text, language, format...)</li>
<li>Submit your request!</li>
<li>The results will be shown in the lower part of the screen, propertly formatted.</li>
</ol>
</div>
<div class="panel-heading"><i class="fa fa-sign-in"></i> Follow us on <a href="http://www.github.com/gsi-upm/senpy">GitHub</a></div>
</div>
<div class="panel panel-default">
<div class="panel-heading"><i class="fa fa-child"></i> Enjoy.</div>
@ -95,11 +71,9 @@ I cannot believe it!</textarea></div>
<div id ="params">
</div>
</br>
<button id="preview" type="button" onclick="load_JSON()" name="type">Preview!</button>
<a id="preview" class="btn btn-lg btn-primary" href="#" onclick="load_JSON()">Analyse!</a>
<!--<button id="visualise" name="type" type="button">Visualise!</button>-->
<button type="submit" >Download!</button>
</form>
</header>
<div id="content">
<span id="input_request"></span>
<pre id="results"></pre>
@ -110,6 +84,7 @@ I cannot believe it!</textarea></div>
<a href="http://www.gsi.dit.upm.es" target="_blank"><img class="center-block" src="static/img/gsi.png"/> </a>
</div>
</div>
<div id="footer">
<div class="container">
<div id="site-info">
@ -122,7 +97,6 @@ I cannot believe it!</textarea></div>
</div>
</div>
</div>
</body>
<link href='http://fonts.googleapis.com/css?family=Architects+Daughter' rel='stylesheet' type='text/css'>
</html>