Skip to content

Commit

Permalink
utils.py: Fixed a bug in drop_privileges() where it wasn't converti…
Browse files Browse the repository at this point in the history
…ng uid values given as strings into integers. Note that this doesn't impact Gate One at all since it pre-converts to integers before calling `drop_privileges()` anyway. A bug is a bug though.

utils.py:  The `drop_privileges()` function will now set `USER`, `LOGNAME`, `SHELL`, and `HOME` after it drops privileges.
app_terminal.py:  Before spawning a new terminal the environment variables will name have the default `os.environ` applied so the shell process will get the defaults in addition to any extras/overrides set by Gate One or the "environment_vars" setting.
Themes:  Switched from "Ubuntu, Arial Black, sans-serif" to "Ubuntu, Arial, sans-serif" because Arial Black looks fugly on Windows for some reason.
Themes:  Tweaked the CSS that controls the application icon grid in the New Workspace Workspace.
REMOVED: Mobile plugin:  The function it provides has been moved to various individual CSS files in the form of CSS media queries.  Not that using a mobile browser is worthwhile anyway...  Chrome for Android doesn't register kedown/keyup events (see my >1 year old bug: https://code.google.com/p/chromium/issues/detail?id=118639) which means you can't use the backspace key and Firefox mobile doesn't fire componsition* events properly (a new bug which I opened today:  https://bugzilla.mozilla.org/show_bug.cgi?id=921209).
terminal_input.js:  Not that it matters but I cleaned up the code that deals with mobile browsers a bit.
  • Loading branch information
liftoff committed Sep 27, 2013
1 parent c163384 commit 1646f8f
Show file tree
Hide file tree
Showing 23 changed files with 268 additions and 98 deletions.
5 changes: 3 additions & 2 deletions gateone/applications/terminal/app_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

# Meta information about the plugin. Your plugin doesn't *have* to have this
# but it is a good idea.
__version__ = '1.0'
__version__ = '1.2'
__license__ = "AGPLv3 or Proprietary (see LICENSE.txt)"
__version_info__ = (1, 0)
__version_info__ = (1, 2)
__author__ = 'Dan McDougall <[email protected]>'

# I like to start my files with imports from Python's standard library...
Expand Down Expand Up @@ -1161,6 +1161,7 @@ def new_terminal(self, settings):
'GO_SESSION_DIR': options.session_dir,
'GO_USER_SESSION_DIR': user_session_dir,
}
env.update(os.environ) # Add the defaults for this system
env.update(environment_vars) # Apply policy-based environment
if self.plugin_env_hooks:
# This allows plugins to add/override environment variables
Expand Down
18 changes: 0 additions & 18 deletions gateone/applications/terminal/plugins/mobile/mobile.py

This file was deleted.

23 changes: 0 additions & 23 deletions gateone/applications/terminal/plugins/mobile/templates/mobile.css

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
right: 2em;
bottom: 0.1em;
}
/* Optimize Gate One for mobile devices */
@media only screen and (max-width: 800px) {
.✈playbackControls {
display: none; /* Small screens really don't have room for this */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
right: 2em;
bottom: 0.1em;
}
/* Optimize Gate One for mobile devices */
@media only screen and (max-width: 800px) {
.✈playbackControls {
display: none; /* Small screens really don't have room for this */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
right: 2em;
bottom: 0.1em;
}
/* Optimize Gate One for mobile devices */
@media only screen and (max-width: 800px) {
.✈playbackControls {
display: none; /* Small screens really don't have room for this */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@
right: 2em;
bottom: 0.1em;
}
/* Optimize Gate One for mobile devices */
@media only screen and (max-width: 800px) {
.✈playbackControls {
display: none; /* Small screens really don't have room for this */
}
}
4 changes: 4 additions & 0 deletions gateone/applications/terminal/static/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ go.Base.update(GateOne.Terminal, {
If *term* is not given the currently-selected terminal will be used.
*/
logInfo('sendString(): ' + chars);
var term = term || localStorage[go.prefs.prefix+'selectedTerminal'],
message = {'chars': chars, 'term': term};
go.ws.send(JSON.stringify({'terminal:write_chars': message}));
Expand Down Expand Up @@ -1330,6 +1331,9 @@ go.Base.update(GateOne.Terminal, {
Returns a 'pastearea' (textarea) element meant for placement above terminals for the purpose of enabling proper copy & paste.
*/
// if ('ontouchstart' in document.documentElement) { // Touch-enabled devices only
// return; // Don't create the pastearea on mobile devices since it messes up the ability to scroll
// }
var pastearea = u.createElement('textarea', {'id': 'pastearea'+term, 'class': '✈pastearea'}),
// The following functions control the copy & paste capability
pasteareaOnInput = function(e) {
Expand Down
19 changes: 10 additions & 9 deletions gateone/applications/terminal/static/terminal_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,8 @@ GateOne.Base.update(GateOne.Terminal.Input, {
init: function() {
/**:GateOne.Terminal.Input.init()
Creates GateOne.Terminal.Input.inputNode to capture keys/IME composition and attaches appropriate events.
Creates `GateOne.Terminal.Input.inputNode` to capture keys/IME composition and attaches appropriate events.
*/
t.Input.inputNode = u.createElement('textarea', {'class': '✈IME'});
go.node.appendChild(t.Input.inputNode);
t.Input.inputNode.addEventListener('compositionstart', t.Input.onCompositionStart, true);
t.Input.inputNode.addEventListener('compositionupdate', t.Input.onCompositionUpdate, true);
t.Input.inputNode.addEventListener('compositionend', t.Input.onCompositionEnd, true);
E.on("go:new_workspace", go.Terminal.Input.disableCapture);
E.on("terminal:new_terminal", go.Terminal.Input.capture);
E.on("go:visible", function() {
Expand Down Expand Up @@ -324,6 +319,9 @@ GateOne.Base.update(GateOne.Terminal.Input, {
if (!t.Input.inputNode) {
t.Input.inputNode = u.createElement('input', {'class': '✈IME', 'style': {'position': 'fixed', 'z-index': 99999, 'top': '-9999px', 'left': '-9999px'}});
go.node.appendChild(t.Input.inputNode);
t.Input.inputNode.addEventListener('compositionstart', t.Input.onCompositionStart, true);
t.Input.inputNode.addEventListener('compositionupdate', t.Input.onCompositionUpdate, true);
t.Input.inputNode.addEventListener('compositionend', t.Input.onCompositionEnd, true);
}
if (!t.Input.addedEventListeners) {
t.Input.inputNode.addEventListener('input', t.Input.onInput, false);
Expand Down Expand Up @@ -364,11 +362,13 @@ GateOne.Base.update(GateOne.Terminal.Input, {
// The 'blur' event can be called when focus shifts around for pasting.
return; // Act as if we were never called to avoid flashing the overlay
}
t.Input.inputNode.removeEventListener('input', t.Input.onInput, false);
t.Input.inputNode.tabIndex = null;
if (t.Input.InputNode) {
t.Input.inputNode.removeEventListener('input', t.Input.onInput, false);
t.Input.inputNode.tabIndex = null;
t.Input.inputNode.removeEventListener('blur', t.Input.disableCapture, true);
}
go.node.removeEventListener('keydown', t.Input.onKeyDown, true);
go.node.removeEventListener('keyup', t.Input.onKeyUp, true);
t.Input.inputNode.removeEventListener('blur', t.Input.disableCapture, true);
terms.forEach(function(termNode) {
termNode.removeEventListener('paste', t.Input.onPaste, false);
termNode.removeEventListener('mousedown', t.Input.onMouseDown, false);
Expand Down Expand Up @@ -452,6 +452,7 @@ GateOne.Base.update(GateOne.Terminal.Input, {
offset = u.getOffset(cursor);
// This tells the other keyboard input events to suspend their actions until the compositionupdate or compositionend event.
t.Input.composition = true;
// This makes the IME show up right where the cursor is:
t.Input.inputNode.style['top'] = offset.top + "px";
t.Input.inputNode.style['left'] = offset.left + "px";
},
Expand Down
6 changes: 6 additions & 0 deletions gateone/applications/terminal/templates/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,9 @@ span.✈termline {
.✈font_ubuntu {
font-family: 'Ubuntu Mono';
}
@media only screen and (max-width: 800px) {
.✈pastearea {
/* Touchscreens don't work with the pastearea */
display: none;
}
}
6 changes: 6 additions & 0 deletions gateone/applications/terminal/templates/themes/black.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ span.✈f0.✈b0 { color: #444; background-color: transparent; } /* Black on Bla
margin: 0 auto;
width: 100%;
}
@media only screen and (max-width: 800px) {
.✈terminal pre {
/* On mobile devices it's best to let the device's default monospace font handle things */
font-family: monospace !important;
}
}
6 changes: 6 additions & 0 deletions gateone/applications/terminal/templates/themes/dark-black.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,9 @@ span.✈cursor { color: #000; background-color: #ccc; }
margin: 0 auto;
width: 100%;
}
@media only screen and (max-width: 800px) {
.✈terminal pre {
/* On mobile devices it's best to let the device's default monospace font handle things */
font-family: monospace !important;
}
}
6 changes: 6 additions & 0 deletions gateone/applications/terminal/templates/themes/solarized.css
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ span.✈cursor { color: #002b36; background-color: #eee8d5; }
margin: 0 auto;
width: 100%;
}
@media only screen and (max-width: 800px) {
.✈terminal pre {
/* On mobile devices it's best to let the device's default monospace font handle things */
font-family: monospace !important;
}
}
6 changes: 6 additions & 0 deletions gateone/applications/terminal/templates/themes/white.css
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@ span.✈reverse { background-color: #aaa; color: #fff; }
margin: 0 auto;
width: 100%;
}
@media only screen and (max-width: 800px) {
.✈terminal pre {
/* On mobile devices it's best to let the device's default monospace font handle things */
font-family: monospace !important;
}
}
2 changes: 1 addition & 1 deletion gateone/gateone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__version_info__ = (1, 2, 0)
__license__ = "AGPLv3" # ...or proprietary (see LICENSE.txt)
__author__ = 'Dan McDougall <[email protected]>'
__commit__ = "20130925212401" # Gets replaced by git (holds the date/time)
__commit__ = "20130925212405" # Gets replaced by git (holds the date/time)

# NOTE: Docstring includes reStructuredText markup for use with Sphinx.
__doc__ = '''\
Expand Down
4 changes: 2 additions & 2 deletions gateone/static/gateone.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 24 additions & 27 deletions gateone/static/gateone_input.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,33 +58,30 @@ GateOne.Base.update(GateOne.Input, {
go.node.addEventListener('keydown', go.Input.onKeyDown, true);
go.node.addEventListener('keyup', go.Input.onKeyUp, true);
// Add some useful touchscreen events
if ('ontouchstart' in document.documentElement) { // Touch-enabled devices only
v.displayMessage("Touch screen detected:<br>Swipe left/right/up/down to switch workspaces.");
var style = window.getComputedStyle(go.node, null);
go.node.addEventListener('touchstart', function(e) {
v.displayMessage("touchstart");
var touch = e.touches[0];
go.Input.touchstartX = touch.pageX;
go.Input.touchstartY = touch.pageY;
}, true);
go.node.addEventListener('touchmove', function(e) {
v.displayMessage("touchmove");
var touch = e.touches[0];
if (touch.pageX < go.Input.touchstartX && (go.Input.touchstartX - touch.pageX) > 20) {
v.slideRight();
} else if (touch.pageX > go.Input.touchstartX && (touch.pageX - go.Input.touchstartX) > 20) {
v.slideLeft();
} else if (touch.pageY < go.Input.touchstartY && (go.Input.touchstartY - touch.pageY) > 20) {
v.slideDown();
} else if (touch.pageY > go.Input.touchstartY && (touch.pageY - go.Input.touchstartY) > 20) {
v.slideUp();
}
e.preventDefault();
}, true);
setTimeout(function() {
u.hideElements('.✈pastearea');
}, 3000);
}
// if ('ontouchstart' in document.documentElement) { // Touch-enabled devices only
// v.displayMessage("Touch screen detected:<br>Swipe left/right/up/down to switch workspaces.");
// // var style = window.getComputedStyle(go.node, null);
// go.node.addEventListener('touchstart', function(e) {
// // v.displayMessage("touchstart");
// var touch = e.touches[0];
// go.Input.touchstartX = touch.pageX;
// go.Input.touchstartY = touch.pageY;
// }, true);
// go.node.addEventListener('touchmove', function(e) {
// // v.displayMessage("touchmove");
// var touch = e.touches[0];
// if (touch.pageX < go.Input.touchstartX && (go.Input.touchstartX - touch.pageX) > 20) {
// v.slideRight();
// } else if (touch.pageX > go.Input.touchstartX && (touch.pageX - go.Input.touchstartX) > 20) {
// v.slideLeft();
// } else if (touch.pageY < go.Input.touchstartY && (go.Input.touchstartY - touch.pageY) > 20) {
// v.slideDown();
// } else if (touch.pageY > go.Input.touchstartY && (touch.pageY - go.Input.touchstartY) > 20) {
// v.slideUp();
// }
// e.preventDefault();
// }, true);
// }
},
modifiers: function(e) {
// Given an event object, returns an object with booleans for each modifier key (shift, alt, ctrl, meta)
Expand Down
2 changes: 1 addition & 1 deletion gateone/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=0">
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1.0, minimum-scale=1.0, user-scalable=0" />
{% if location == 'default' %}
<title>Gate One - {{hostname}}</title>
{% else %}
Expand Down
44 changes: 41 additions & 3 deletions gateone/templates/themes/black.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
text-align: center;
width: 80%;
background-color: #000;
font-family: Ubuntu, Arial Black, sans-serif;
font-family: Ubuntu, Arial, sans-serif;
border-bottom: 1px solid #222;
margin: 0 auto;
}
Expand All @@ -120,11 +120,13 @@
padding-right: 1.5em;
width: 15%;
height: 10em;
font-family: sans-serif;
overflow: hidden;
}
.✈application p {
.✈application span {
margin: 0 0 1em 0;
word-break: break-all;
word-wrap: break-word;
display: inline-block;
}
.✈application:hover {
box-shadow: 0 0 0.6em #444;
Expand Down Expand Up @@ -916,3 +918,39 @@ div.✈widget_close .✈svgplain { fill: #FFFFFF; }
.✈hsplitbar:hover {
cursor: row-resize;
}
/* Optimize Gate One for mobile devices */
@media only screen and (max-width: 800px) {
.✈toolbar {
right: 0.25em;
font-size: 100%;
-webkit-transform: scale(2) translate(-40%, 25%);
/* For whatever reason scaling doesn't work properly in Firefox Mobile but that's OK since the icons appear to be big enough to usable regardless */
-ms-transform: scale(2) translate(-40%, 25%); /* We'll see */
-o-transform: scale(2) translate(-40%, 25%); /* Yet to be tested */
transform: scale(2) translate(-40%, 25%); /* Yet to be tested */
}
.✈toolbar svg {
margin-bottom: 1em; /* So they do not overlap */
}
.✈sideinfo {
display: none; /* Not enough room for it on mobile */
}
.✈app_grid {
width: 90%;
margin: 0 auto;
text-align: center;
}
.✈application {
display: inline-block;
margin-top: 0.5em;
border-radius: 0.5em;
padding-left: 0.5em;
padding-right: 0.5em;
width: 6.5em;
height: 8.5em;
}
.✈application span {
margin: 0 0 0.5em 0;
}
div.✈appicon svg { width: 4em; height: 4em; }
}
Loading

0 comments on commit 1646f8f

Please sign in to comment.