Skip to content

Commit

Permalink
Merge pull request #31 from abhardwaj/landing_page
Browse files Browse the repository at this point in the history
Update the landing page and console
  • Loading branch information
Albert Carter committed May 28, 2015
2 parents c969676 + aaf00bd commit 001391a
Show file tree
Hide file tree
Showing 7 changed files with 232 additions and 208 deletions.
27 changes: 15 additions & 12 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
django==1.5
south
psycopg2
numpy
thrift
sqlalchemy
scorpionsql
python-dateutil
pycrypto
nltk
textblob
sqlparse
Django==1.5
nltk==3.0.2
numpy==1.9.1
psycopg2==2.5.4
pycrypto==2.6.1
pyparsing==2.0.3
python-dateutil==2.3
scorpionsql==0.0.4
six==1.8.0
South==1.0.1
SQLAlchemy==0.9.8
sqlparse==0.1.15
textblob==0.9.0
thrift==0.9.2
viz==0.0.5
2 changes: 1 addition & 1 deletion src/account/templates/minimal-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="initial-scale=1.0 user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="Description" content="DataHub is a (GitHub like) hosted platform for organizing, managing, sharing, collaborating, and making sense of data. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />
<meta name="Description" content="DataHub is a (GitHub-Like) Data Ecosystem for Individuals, Teams and People. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />


<link rel="stylesheet" type="text/css" href="/static/css/datahub.css"/>
Expand Down
2 changes: 1 addition & 1 deletion src/apps/console/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="initial-scale=1.0 user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="Description" content="DataHub is a (GitHub-like) hosted platform for organizing, managing, sharing, collaborating, and making sense of data. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />
<meta name="Description" content="DataHub is a (GitHub-Like) Data Ecosystem for Individuals, Teams and People. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />


<link rel="stylesheet" type="text/css" href="/static/css/datahub.css" />
Expand Down
273 changes: 144 additions & 129 deletions src/apps/console/templates/console.html
Original file line number Diff line number Diff line change
@@ -1,157 +1,172 @@
{% extends "layout.html" %}
{% block content %}
<div class="container">
<div id="dh-console-container">
<div id="dh-console">
<pre class="ascii-art-console">
{% extends "layout.html" %} {% block content %}
<div class="container-fluid">
<div id="dh-console-container">
<div id="dh-console">
<pre class="ascii-art-console">
_____ _ _ _ _
| __ \ | | | | | | | |
| | | | __ _| |_ __ _| |__| |_ _| |__
| | | |/ _` | __/ _` | __ | | | | '_ \
| |__| | (_| | || (_| | | | | |_| | |_) |
|_____/ \__,_|\__\__,_|_| |_|\__,_|_.__/
</pre>
<br /><br />
<div class="punch">DataHub is a (GitHub like) hosted platform for organizing, managing, sharing, collaborating, and making sense of data.
</pre>
<br />
<br />
<div class="punch">DataHub is a (GitHub-Like) Data Ecosystem for Individuals, Teams and People.
</div>
<br />
</div>
</div>
</div>
<br />
</div>
</div>
</div>

<script type="text/javascript">

if (typeof String.prototype.startsWith != 'function') {
// see below for better implementation!
String.prototype.startsWith = function (str){
return this.indexOf(str) == 0;
};
// see below for better implementation!
String.prototype.startsWith = function(str) {
return this.indexOf(str) == 0;
};
}

function print_result (res, term) {
if (res.num_tuples >= 0) {
var col_names = []
var separator = []
function print_result(res, term) {
if (res.num_tuples >= 0) {
var col_names = []
var separator = []

$.each(res.field_names, function(field_idx, field) {
col_names.push(field)
separator.push('------------')
});
$.each(res.field_names, function(field_idx, field) {
col_names.push(field)
separator.push('------------')
});

term.echo(col_names.join('\t'))
term.echo(separator.join(''))
term.echo(col_names.join('\t'))
term.echo(separator.join(''))

$.each(res.tuples, function(tuple_idx, tuple) {
values = []
$.each(tuple.cells, function(cell_idx, cell) {
values.push(cell)
});
term.echo(values.join('\t'))
});
$.each(res.tuples, function(tuple_idx, tuple) {
values = []
$.each(tuple.cells, function(cell_idx, cell) {
values.push(cell)
});
term.echo(values.join('\t'))
});

term.echo('')
term.echo(res.num_tuples + ' rows returned.')
if (res.num_more_tuples && res.num_more_tuples > 0) {
term.echo(res.num_more_tuples + ' more rows available. Type \'more\' to see more rows.')
}
} else {
if (res.status) {
term.echo('success')
term.echo('')
term.echo(res.num_tuples + ' rows returned.')
if (res.num_more_tuples && res.num_more_tuples > 0) {
term.echo(res.num_more_tuples + ' more rows available. Type \'more\' to see more rows.')
}
} else {
term.echo('error')
if (res.status) {
term.echo('success')
} else {
term.echo('error')
}
}
}
}

function set_console_height() {
var h = window.innerHeight;
$("#dh-console").height(h * .8);
return;
}

$(document).ready(function($) {
var kCmdList = [
'** Any SQL Query **',
'connect &lt;repo-base&gt; \t -- connect to a repo-base',
'mkrepo &lt;repo-name&gt; \t -- to create a new repository',
'rm &lt;repo-name [-f]&gt; \t\t -- to remove a repository',
'ls \t\t\t\t\t -- to list repositories',
'ls &lt;repo-name&gt; \t\t -- to list tables in a repository',
'schema &lt;table-name&gt; \t\t -- to print schema info of a table'
]

set_console_height();

var login = '{{login}}'
var transport = new Thrift.Transport(window.location.protocol + '//' + window.location.host + '/service/json');
var protocol = new Thrift.Protocol(transport);
var client = new DataHubClient(protocol);
var con = new Connection({'user': login, 'repo_base': login});
var kCmdList = [
'** Any SQL Query **',
'connect &lt;repo-base&gt; \t -- connect to a repo-base',
'mkrepo &lt;repo-name&gt; \t -- to create a new repository',
'rm &lt;repo-name [-f]&gt; \t\t -- to remove a repository',
'ls \t\t\t\t\t -- to list repositories',
'ls &lt;repo-name&gt; \t\t -- to list tables in a repository',
'schema &lt;table-name&gt; \t\t -- to print schema info of a table'
]

$('#dh-console').terminal(
function (command, term) {
try{
var cmd = $.trim(command.toLowerCase())
var login = '{{login}}'
var transport = new Thrift.Transport(window.location.protocol + '//' + window.location.host + '/service/json');
var protocol = new Thrift.Protocol(transport);
var client = new DataHubClient(protocol);
var con = new Connection({
'user': login,
'repo_base': login
});

if (cmd == ''){
return
}
if (cmd.startsWith('connect')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {
con.repo_base = args[1]
term.echo("Connected to: " + con.repo_base)
} else {
term.error ('HELP: connect &lt;repo-base&gt;')
}
} else if (cmd.startsWith('mkrepo')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {
res = client.create_repo(con, args[1])
print_result(res, term)
} else {
term.error ('HELP: mkrepo &lt;repo-name&gt;')
}
} else if (cmd.startsWith('rm')) {
var args = cmd.split(' ', 3)
if (args.length > 1) {
force = false
if (args.length == 3 && args[2] == '-f') {
force = true
$('#dh-console').terminal(
function(command, term) {
try {
var cmd = $.trim(command.toLowerCase())

if (cmd == '') {
return
}
if (cmd.startsWith('connect')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {

// trim blank spaces and semicolons from usernames
var username = args[1].trim();
if (username.substr(username.length - 1) === ";") {
username = username.substring(0, username.length - 1);
}

con.repo_base = username;
term.echo("Connected to: " + con.repo_base)
} else {
term.error('HELP: connect &lt;repo-base&gt;')
}
} else if (cmd.startsWith('mkrepo')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {
res = client.create_repo(con, args[1])
print_result(res, term)
} else {
term.error('HELP: mkrepo &lt;repo-name&gt;')
}
} else if (cmd.startsWith('rm')) {
var args = cmd.split(' ', 3)
if (args.length > 1) {
force = false
if (args.length == 3 && args[2] == '-f') {
force = true
}
res = client.delete_repo(con, args[1], force)
print_result(res, term)
} else {
term.error('HELP: rm &lt;repo-name&gt; [-f]')
}
} else if (cmd.startsWith('desc')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {
res = client.get_schema(con, args[1])
print_result(res, term)
} else {
term.error('HELP: desc &lt;table-name&gt;')
}
} else if (cmd.startsWith('ls')) {
var args = cmd.split(' ', 2)
res = null
if (args.length > 1) {
res = client.list_tables(con, args[1])
} else {
res = client.list_repos(con)
}
print_result(res, term)
} else if (cmd.startsWith('help')) {
for (var cmd in kCmdList) {
term.echo(kCmdList[cmd])
}
} else {
res = client.execute_sql(con, cmd);
print_result(res, term)
}
} catch (error) {
term.error(error.message);
}
res = client.delete_repo(con, args[1], force)
print_result(res, term)
} else {
term.error ('HELP: rm &lt;repo-name&gt; [-f]')
}
} else if (cmd.startsWith('desc')) {
var args = cmd.split(' ', 2)
if (args.length > 1) {
res = client.get_schema(con, args[1])
print_result(res, term)
} else {
term.error ('HELP: desc &lt;table-name&gt;')
}
} else if (cmd.startsWith('ls')) {
var args = cmd.split(' ', 2)
res = null
if (args.length > 1) {
res = client.list_tables(con, args[1])
} else {
res = client.list_repos(con)
}
print_result(res, term)
} else if (cmd.startsWith('help')) {
for (var cmd in kCmdList) {
term.echo(kCmdList[cmd])
}
} else {
res = client.execute_sql(con, cmd);
print_result(res, term)
}, {
prompt: '{{login}}@' + con.repo_base + '> ',
greetings: 'Welcome to DataHub!\nConnected to: ' + con.repo_base
}
} catch(error){
term.error(error.message);
}
}, {
prompt: '{{login}}@' + con.repo_base + '> ',
greetings: 'Welcome to DataHub!\nConnected to: ' + con.repo_base}
);

});
);

});
</script>
{% endblock %}


Binary file not shown.
2 changes: 1 addition & 1 deletion src/browser/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<meta name="HandheldFriendly" content="true" />
<meta name="viewport" content="initial-scale=1.0 user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="Description" content="DataHub is a (GitHub-like) hosted platform for organizing, managing, sharing, collaborating, and making sense of data. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />
<meta name="Description" content="DataHub is a (GitHub-Like) Data Ecosystem for Individuals, Teams and People. It provides an efficient platform and easy to use tools/interfaces for publishing of your own data (hosting, sharing, collaboration), using other’s data (querying, linking), and making sense of data (analysis, visualization)" />


<link rel="stylesheet" type="text/css" href="/static/css/datahub.css" />
Expand Down

0 comments on commit 001391a

Please sign in to comment.