Skip to content

Commit

Permalink
Various changes and tweaks to WebUI
Browse files Browse the repository at this point in the history
  • Loading branch information
dmptrluke committed Apr 2, 2015
1 parent a67d577 commit fe15e4d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 22 deletions.
17 changes: 16 additions & 1 deletion cloudbot/web/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,20 @@ body {
}

#about-dialog {
top:20%;
top: 20%;
}

footer {
margin: 5em 0;
}

footer li {
float: left;
margin-right: 1.5em;
margin-bottom: 1.5em
}

footer p {
clear: left;
margin-bottom: 0
}
11 changes: 9 additions & 2 deletions cloudbot/web/templates/commands.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
{% block content %}
<div class="row">
<div class="col-lg-12">

<div class="page-header">
<h2 id="container">Command List</h2>
</div>

<p class="lead">{{ bot_name }} has a large selection of commands that can do all kinds of useful tasks.
Below is an automatically-generated list of every command the bot currently knows.</p>
<div class="alert alert-dismissible alert-warning">
<button type="button" class="close" data-dismiss="alert">×</button>
<h4>Under Construction!</h4>
<p>This page is still under construction, and may provide incorrect data.</p>
</div>
<table class="table table-striped sortable" id="commands">
<thead>
<tr>
Expand All @@ -26,11 +33,11 @@ <h2 id="container">Command List</h2>
<i class ="glyphicon glyphicon-lock" data-toggle="tooltip" data-placement="left" title="{{ perm }}"></i>
</td>
{% else %}
<td data-value="zzzz"></td>
<td class="hidden-phone hidden-tablet"a data-value="zz"></td>
{% endif %}
</tr>
{% endfor %}
</table>
</div>
</div>
{% endblock %}
{% endblock %}glyphicon glyphicon-th-large
12 changes: 10 additions & 2 deletions cloudbot/web/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" data-toggle="tooltip" data-placement="bottom" title="Return to top" onclick="$('html,body').animate({scrollTop:0},'slow');return false;">{{ bot_name }}</a>
<a class="navbar-brand" data-toggle="tooltip" data-placement="bottom" title="Return to top"
onclick="$('html,body').animate({scrollTop:0},'slow');return false;">{{ bot_name }}</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
Expand All @@ -54,6 +55,10 @@
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#about-dialog">About</a>

</li>
<li>
<a data-container="body" data-toggle="popover" data-placement="bottom" data-content="todo admin" class="glyphicon glyphicon-tasks"></a>
</li>
</ul>
</div>
Expand All @@ -62,6 +67,7 @@
</nav>

<div class="container">

{% block content %}{% endblock %}
</div>

Expand All @@ -83,6 +89,7 @@ <h4 class="modal-title">About Me</h4>
</div>
</div>


<!-- javascript -->
{% block scripts %}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
Expand All @@ -91,7 +98,8 @@ <h4 class="modal-title">About Me</h4>
<script src="/s/js/bootstrap-sortable.js"></script>
<script>
$(function () {
$('[data-toggle="tooltip"]').tooltip()
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="popover"]').popover();
})
</script>
{% endblock %}
Expand Down
32 changes: 16 additions & 16 deletions plugins/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,56 +90,56 @@ def qrcode(text):

# basic text tools

@hook.command("capitalise", "capitalize")
@hook.command("capitalize", "capitalise")
def capitalize(text):
"""capitalize <string> -- Capitalizes <string>.
"""<string> -- Capitalizes <string>.
:type text: str
"""
return ". ".join([sentence.capitalize() for sentence in text.split(". ")])


@hook.command
def upper(text):
"""upper <string> -- Convert string to uppercase."""
"""<string> -- Convert string to uppercase."""
return text.upper()


@hook.command
def lower(text):
"""lower <string> -- Convert string to lowercase."""
"""<string> -- Convert string to lowercase."""
return text.lower()


@hook.command
def titlecase(text):
"""title <string> -- Convert string to title case."""
"""<string> -- Convert string to title case."""
return text.title()


@hook.command
def swapcase(text):
"""swapcase <string> -- Swaps the capitalization of <string>."""
"""<string> -- Swaps the capitalization of <string>."""
return text.swapcase()


# encoding

@hook.command("rot13")
def rot13_encode(text):
"""rot13 <string> -- Encode <string> with rot13."""
"""<string> -- Encode <string> with rot13."""
encoder = codecs.getencoder("rot-13")
return encoder(text)[0]


@hook.command("base64")
def base64_encode(text):
"""base64 <string> -- Encode <string> with base64."""
"""<string> -- Encode <string> with base64."""
return base64.b64encode(text.encode()).decode()


@hook.command("debase64", "unbase64")
def base64_decode(text, notice):
"""unbase64 <string> -- Decode <string> with base64."""
"""<string> -- Decode <string> with base64."""
try:
return base64.b64decode(text.encode()).decode()
except binascii.Error:
Expand All @@ -148,7 +148,7 @@ def base64_decode(text, notice):

@hook.command("isbase64", "checkbase64")
def base64_check(text):
"""isbase64 <string> -- Checks if <string> is a valid base64 encoded string"""
"""<string> -- Checks if <string> is a valid base64 encoded string"""
try:
base64.b64decode(text.encode())
except binascii.Error:
Expand All @@ -159,14 +159,14 @@ def base64_check(text):

@hook.command
def unescape(text):
"""unescape <string> -- Unicode unescapes <string>."""
"""<string> -- Unicode unescapes <string>."""
decoder = codecs.getdecoder("unicode_escape")
return decoder(text)[0]


@hook.command
def escape(text):
"""escape <string> -- Unicode escapes <string>."""
"""<string> -- Unicode escapes <string>."""
encoder = codecs.getencoder("unicode_escape")
return encoder(text)[0].decode()

Expand All @@ -176,7 +176,7 @@ def escape(text):

@hook.command
def length(text):
"""length <string> -- Gets the length of <string>"""
"""<string> -- Gets the length of <string>"""
return "The length of that string is {} characters.".format(len(text))


Expand All @@ -185,7 +185,7 @@ def length(text):

@hook.command
def reverse(text):
"""reverse <string> -- Reverses <string>."""
"""<string> -- Reverses <string>."""
return text[::-1]


Expand All @@ -194,7 +194,7 @@ def reverse(text):

@hook.command("hash")
def hash_command(text):
"""hash <string> -- Returns hashes of <string>."""
"""<string> -- Returns hashes of <string>."""
return ', '.join(x + ": " + getattr(hashlib, x)(text.encode("utf-8")).hexdigest()
for x in ['md5', 'sha1', 'sha256'])

Expand All @@ -218,7 +218,7 @@ def leet(text):
# Based on plugin by FurCode - <https://github.com/FurCode/RoboCop2>
@hook.command
def derpify(text):
"""derpify <text> - returns some amusing responses from your input."""
"""<text> - returns some amusing responses from your input."""
string = text.upper()
pick_the = random.choice(["TEH", "DA"])
pick_e = random.choice(["E", "3", "A"])
Expand Down
2 changes: 1 addition & 1 deletion plugins/wolframalpha.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@hook.command("wolframalpha", "wa", "calc", "ca", "math")
def wolframalpha(text, bot):
"""w<query> -- Computes <query> using Wolfram Alpha."""
"""<query> -- Computes <query> using Wolfram Alpha."""
api_key = bot.config.get("api_keys", {}).get("wolframalpha", None)
if not api_key:
return "error: missing api key"
Expand Down

0 comments on commit fe15e4d

Please sign in to comment.