Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4e9d870
add shortcuts to editor UI
greenlaw110 Apr 6, 2013
e3eb9a8
F2 to rename current source;escape to cancel rename or add new source
greenlaw110 Apr 7, 2013
fd96c0c
Add shortcut information to about dialog
greenlaw110 Apr 7, 2013
5947988
alt-1~9 to select the nth source file, allow open editor from the emb…
greenlaw110 Apr 7, 2013
ffc6b48
update open in fiddle logic
greenlaw110 Apr 7, 2013
a487fab
support messages.xx as resource files for i18n
greenlaw110 Apr 7, 2013
8ba0b4a
update embed top-bar button group css
greenlaw110 Apr 7, 2013
d8e8127
allow shortname msg. or m. for resource file
greenlaw110 Apr 7, 2013
6b69ae3
fix issue: cannot scoll para box
greenlaw110 Apr 11, 2013
34ae55c
gu
greenlaw110 Apr 11, 2013
4aeb4d6
gu
greenlaw110 Apr 11, 2013
e5a5814
update rythm version
greenlaw110 Apr 11, 2013
5e44667
gu
greenlaw110 Apr 12, 2013
7a4def6
enable engine configuration
greenlaw110 Apr 13, 2013
0fef2d0
fix NPE issue
greenlaw110 Apr 13, 2013
97383cb
default mode to prod
greenlaw110 Apr 13, 2013
00f0b3b
gu
greenlaw110 Apr 13, 2013
2046d17
update rythm engine version
greenlaw110 Apr 23, 2013
17d41a2
update to rythmengine-1.0-b8
greenlaw110 May 10, 2013
2d94a79
update dependencies.yml
greenlaw110 May 10, 2013
e3f3c07
change css
greenlaw110 May 10, 2013
00112e6
change css
greenlaw110 May 10, 2013
6763430
change css
greenlaw110 May 10, 2013
bb8069b
gu
greenlaw110 May 11, 2013
4eade9d
gu
greenlaw110 May 12, 2013
4152efd
gu
greenlaw110 May 12, 2013
2f19121
gu
greenlaw110 May 12, 2013
a3d36f4
gu
greenlaw110 May 12, 2013
b44b3b2
gu
greenlaw110 May 12, 2013
337790c
update rythm version
greenlaw110 May 13, 2013
db8956b
upgrade rythm version to fix the sandbox file IO security hole
greenlaw110 May 19, 2013
396def0
gu
greenlaw110 May 19, 2013
8f3f01d
gu
greenlaw110 May 26, 2013
0a8e071
update rythm version
greenlaw110 May 26, 2013
05ab410
update rythm
greenlaw110 May 26, 2013
38bd78a
update engine version
greenlaw110 Jun 8, 2013
fceffc8
add view in new tab shortcut to embedded view
greenlaw110 Jul 21, 2013
c0e80be
update play-rythm version
greenlaw110 Apr 12, 2014
78d57cc
gu
greenlaw110 Aug 3, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100755 → 100644
Empty file.
Empty file modified LICENSE.txt
100755 → 100644
Empty file.
12 changes: 7 additions & 5 deletions angular-seed/app/css/app.css
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@

.params .CodeMirror {
height: auto;
max-height: 300px;
overflow-y: auto;
min-height: 50px;
}

.source .CodeMirror {
Expand All @@ -76,9 +75,12 @@
}

.template_error {
background-color: #F2DEDE;
color: #B94A48;
border-color: #EED3D7;
background-color: #000;
color: #F04441;
border-color: #000;
}
#RESULT_PANEL code, #RESULT_PANEL pre {
font-family: "Source Code Pro Semibold","Envy Code R",Consolas, Monaco, Menlo, 'Courier New', monospace;
}

.file_active {
Expand Down
4 changes: 2 additions & 2 deletions angular-seed/app/embed.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
.embedded .nav.nav-tabs li a {border: none;border-radius: 0;background: transparent;}
.embedded .nav.nav-tabs li:not(.active) a:hover {text-decoration: underline;}
.embedded form {margin-bottom: 1px;}
.embedded form .toolbar {margin-top: 5px;}
.embedded form .toolbar {margin-top: 5px;position: absolute;right:0;}
.embedded .edit_panel input {border-radius: 0;}
.embedded .btn {border-radius: 0;background-image: none;}
.embedded .slight-buttons .btn {background: transparent;border-color: #fff;border-image: none;margin-bottom: -2px;opacity: .5;}
Expand Down Expand Up @@ -136,7 +136,7 @@
var $_ = $(this).find('.tag.lbl');
$_.html($_.data('label')).animate({opacity: 0.7}, 400);
}
}, '.source .CodeMirror, .params .CodeMirror, #RESULT_PANEL div.result')
}, '.source .CodeMirror, .params .CodeMirror, #RESULT_PANEL div.result');
});
setInterval(function(){
if ($('.source .CodeMirror .tag.lbl').size() > 0) return;
Expand Down
Empty file modified angular-seed/app/index-async.html
100755 → 100644
Empty file.
19 changes: 14 additions & 5 deletions angular-seed/app/index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,14 @@
</li>
<li><a class="btn-link" ng-click="showAbout()">About</a></li>
</ul>
<span>
<p class="navbar-text pull-right" ng-show="current">Logged in as {{current}}</p>
<a class="navbar-text pull-right" ng-href="#/login" ng-hide="current">Admin Login</a>
</span>
<ul class="pull-right nav">
<li class="navbar-text" ng-show="current">
Logged in as {{current}}
</li>
<li ng-hide="current">
<a ng-href="#/login">Admin Login</a>
</li>
</ul>
</div>
</div>
</div>
Expand Down Expand Up @@ -113,7 +117,12 @@
}, '.source .CodeMirror, .params .CodeMirror, #RESULT_PANEL div.result')
var wh = $(window).height();
setInterval(function(){
$('.source .CodeMirror').animate({'height': (wh - 220) + 'px'});
var h = wh - 220;
$('.source .CodeMirror').animate({'height': h + 'px'});
var ph = $('.params .CodeMirror').height();
if (ph > h / 2) {
$('.params .CodeMirror').animate({height: (h / 2) + 'px'});
}
}, 1000);
});
setInterval(function(){
Expand Down
53 changes: 45 additions & 8 deletions angular-seed/app/js/controllers.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,43 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
$scope.switchFile = switchFile;
$scope.removeFile = removeFile;
$scope.setMain = setMain;
$scope.editFileName = editFileName;
$scope.cancelEditFileName = cancelEditFileName;
$scope.renameFile = renameFile;
$scope.cancelRenameFile = cancelRenameFile;
$scope.getActiveFile = getActiveFile;
$scope.getMainFile = getMainFile;
$scope.keyEventHandlerForCodeMirror = keyEventHandlerForCodeMirror;
$scope.ta = {
$source: function() {return $('.source textarea');},
$params: function() {return $('.params textarea');}
};
$scope.$focus = false;
$scope.storeCurFocus = function(){
$scope.$focus = $scope.ta.$source;
var $p = $scope.ta.$params();
if ($p.is(":focus")) {
$scope.$focus = $scope.ta.$params;
}
};
$scope.restoreFocus = function() {
setTimeout(function(){
if ($scope.$focus) {
$scope.$focus().focus();
} else {
$('.source textarea').focus();
}
},1);
}

function keyEventHandlerForCodeMirror($event) {
var keyCode = $event.keyCode;
if (keyCode === 10 || keyCode == 13 && $event.ctrlKey) {
run();
} else if (keyCode == 84 && $event.ctrlKey && $event.altKey) /*ctrl-al-t*/ {
// var $t = $scope.ta.$source(), $p = $scope.ta.$params();
// if ($t.is(':focus')) $p.focus();
// else $t.focus();
} else if (keyCode == 113 /*F2*/) {
renameFile();
}
}

Expand Down Expand Up @@ -108,6 +135,7 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
}

function setMain(file) {
if (!file) file = getActiveFile();
_.each($scope.currentCode.files, function (file) {
file.isMain = false;
});
Expand All @@ -122,6 +150,7 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
}

function removeFile(file, noAlert) {
if (!file) file = getActiveFile();
if ($scope.currentCode.files.length > 1) {
if (noAlert || confirm('Delete this template?')) {
$scope.currentCode.files = _.without($scope.currentCode.files, file);
Expand All @@ -140,6 +169,8 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
// 1. not null
// 2. unique
function saveFileName(file) {
if (!file) file = getActiveFile();
if (!file) return;
var editName = file.editName;
if (!editName) {
alert('filename should not be empty');
Expand All @@ -156,20 +187,25 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
file.filename = editName;
file.editing = false;
}
$scope.restoreFocus();
}

function editFileName(file) {
function renameFile(file) {
$scope.storeCurFocus();
if (!file) file = getActiveFile();
file.editName = file.filename;
file.editing = !file.editing;
}

function cancelEditFileName(file) {
function cancelRenameFile(file) {
if (!file) file = getActiveFile();
if (!file.filename) {
removeFile(file, true);
return;
}
file.editName = null;
file.editing = false;
$scope.restoreFocus();
}

function removeCurrentCode() {
Expand Down Expand Up @@ -209,7 +245,7 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
}

function run() {
if ($scope.currentCode.files.length > 0) {
if ($scope.currentCode.files.length > 0) {
if ($scope.running) return;
$scope.running = true;
$scope.resultPageActive = true;
Expand Down Expand Up @@ -246,7 +282,6 @@ function EditorCtrl($scope, $http, $routeParams, $dialog, $location, $timeout) {
newOne.isMain = true;
}
}

}
EditorCtrl.$inject = ['$scope', '$http', '$routeParams', '$dialog', '$location', '$timeout'];

Expand All @@ -262,10 +297,12 @@ function SaveDialogCtrl($scope, dialog, code, $http, saveAsNew) {
}
$http.post('/api/Application/save', code).success(function (code) {
dialog.close(code);
//TODO: $scope.run();
}).error(function (data) {
alert(data);
});
alert(data);
});
}

}

SaveDialogCtrl.$inject = ['$scope', 'dialog', 'code', '$http', 'saveAsNew'];
Expand Down
2 changes: 1 addition & 1 deletion angular-seed/app/js/filters.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ angular.module('myApp.filters', []).
}

function safe_tags_replace(str) {
return str.replace(/[&<>]/g, replaceTag);
return str ? str.replace(/[&<>]/g, replaceTag) : "";
}

return safe_tags_replace(str);
Expand Down
16 changes: 14 additions & 2 deletions angular-seed/app/partials/about.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@
<h3>Rythm Fiddle</h3>
</div>
<div class="modal-body">
<p>Rythm Fiddle is created by <a href="http://github.com/freewind">Freewind</a>
<p><b>Rythm Fiddle</b> is brought to you by <a href="http://github.com/freewind">Freewind</a>
and <a href="http://github.com/greenlaw110">Green</a></p>

<p>Fork me: <a href="https://github.com/freewind/rythmfiddle">https://github.com/freewind/rythmfiddle</a></p>

<p>License: Apache 2</p>
<p>License: <a href="http://www.apache.org/licenses/LICENSE-2.0.html">Apache License, Version 2</a></p>

<p>Use "messages.xx" or "msg.xx" or "m.xx" to name resource files if you need i18n</p>

<p>Shortcut keys</p>
<ul>
<li><b>Ctrl-Enter</b>: Run the fiddle (Only in editors)</li>
<li><b>F2</b>: Rename current source file (Global)</li>
<li><b>Escape</b>: Cancel source file rename (Only in rename input text element)</li>
<li><b>Ctrl-Alt-T</b>: Toggle focus between source editor and param editor (Only in editors)</li>
<li><b>Ctrl-Alt-T</b>: Focus source editor (focus is not in editors</li>
<li><b>Alt-1 ~ 9</b>: Select the nth template source file</li>
</ul>
</div>
<div class="modal-footer">
<a class="btn" ng-click="close()">Close</a>
Expand Down
57 changes: 42 additions & 15 deletions angular-seed/app/partials/editor.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

<hr/>

<div class="btn-toolbar">
<a ng-show="currentCode.id" class="btn" ng-href="/embed/#/{{currentCode.id}}"
title="Show in Compact view" target="_blank" style="width:174px;padding:5px 0"><i class="icon-eye-close"> </i>
Compact View
</a>
</div>
<!--<div class="btn-toolbar">-->
<!--<a ng-show="currentCode.id" class="btn" ng-href="/embed/#/{{currentCode.id}}"-->
<!--title="Show in Compact view" target="_blank" style="width:174px;padding:5px 0"><i class="icon-eye-close"> </i>-->
<!--Compact View-->
<!--</a>-->
<!--</div>-->

<div class="btn-toolbar" ng-show="current">
<a class="btn" style="width: 85px;" ng-href="#/editor" title="create new demo">
Expand Down Expand Up @@ -61,13 +61,13 @@
<span class="btn" title="Add new template" ng-click="newFile()">
<i class="icon-plus"></i>
</span>
<span class="btn" title="Rename current template" ng-click="editFileName(getActiveFile())">
<span class="btn" title="Rename current template" ng-click="renameFile()">
<i class="icon-edit"></i>
</span>
<span class="btn" title="Delete current template" ng-click="removeFile(getActiveFile())">
<span class="btn" title="Delete current template" ng-click="removeFile()">
<i class="icon-remove"></i>
</span>
<span class="btn" title="Set current template as main entry" ng-click="setMain(getActiveFile())"
<span class="btn" title="Set current template as main entry" ng-click="setMain()"
ng-hide="getActiveFile().isMain">
<i class="icon-heart"></i>
</span>
Expand All @@ -80,11 +80,11 @@
</tabs>
<div class="edit_panel form-inline" ng-show="getActiveFile().editing">
<form class="form-inline">
<input type="text" class="input" ng-model="getActiveFile().editName" autofocus="{{getActiveFile().editing}}"/>
<button class="btn" ng-click="saveFileName(getActiveFile())">
<input type="text" class="input" ng-model="getActiveFile().editName" ui-keydown="{esc: 'cancelRenameFile()'}" autofocus="{{getActiveFile().editing}}"/>
<button class="btn" ng-click="saveFileName()">
<i class="icon-ok"></i>
</button>
<span class="btn" ng-click="cancelEditFileName(getActiveFile())">
<span class="btn" ng-click="cancelRenameFile()">
<i class="icon-remove"></i>
</span>
</form>
Expand All @@ -96,9 +96,11 @@
<form name="editorForm">
<div class="source">
<div ng-show="getActiveFile()">
<textarea class="ng-cloak" ui-codemirror="{theme:'rythm-web',mode:'rythm','lineNumbers': true, 'onKeyEvent':'keyEventHandlerForCodeMirror($event)'}"
<textarea class="ng-cloak" ui-codemirror="{theme:'rythm-web',mode:'rythm','lineNumbers': true, 'onKeyEvent':'keyEventHandlerForCodeMirror($event)', 'matchBrackets': true}"
name="codeSource" ui-refresh="getActiveFile().active"
ng-model="getActiveFile().source"
autofocus="autofocus"
ui-event="{focus: storeCurFocus()}"
>@args String who\nHello @who!</textarea>
</div>
<div class="alert alert-info" style="border:none;background:transparent;font-family: tahoma,arial,sans-serif;color:#888">
Expand All @@ -112,7 +114,7 @@
<form name="paramsForm" title="Type in parameters in JSON">
<div class="params">
<textarea class="ng-cloak" ui-codemirror="{theme:'rythm-web',mode:'javascript','onKeyEvent':'keyEventHandlerForCodeMirror($event)'}"
name="codeParams" ng-model="currentCode.params"
name="codeParams" ng-model="currentCode.params" ui-event="{focus: storeCurFocus()}"
placeholder="Params in Json format">{"who": "Rythm"}</textarea>
</div>
</form>
Expand All @@ -131,9 +133,34 @@
<script type="text/javascript">
setInterval(function () {
var h1 = $('.source .CodeMirror').height(),
h2 = $('.params .CodeMirror').height();
h2 = $('.params').height();
$('#RESULT_PANEL pre.result').css({'height': (h1 - h2 - 27) + 'px', 'overflow-y':'auto'});
}, 300);
CodeMirror.commands.save = function(cm){
$('button[ng-click="save()"]').click();
}
$(window).on('keydown', function(event) {
if (event.which == 113) { // F2
$('.btn[ng-click="renameFile()"]').click();
} else {
//console.log(event);
}
});
$(window).on('keyup', function(event){
if (event.which == 84 && event.ctrlKey && event.altKey) { // ctrl-alt-t
var $s = $('.source textarea'), $p = $('.params textarea');
if ($s.is(':focus')) {
$p.focus();
} else {
$s.focus();
}
} else if (event.altKey && (47 < event.which) && (58 > event.which)) {
//alt 1 -> alt 10
var id = event.which - 48;
if (id == 0) id = 10;
$('ul.nav-tabs li:nth-child(' + id + ') a').trigger('click');
}
});
</script>


Expand Down
6 changes: 6 additions & 0 deletions angular-seed/app/partials/embed.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
<div class="source">
<div class="slight-buttons pull-right toolbar">
<span ng-show="getActiveFile()">
<a id="view_in_fiddle" class="btn" target="new" title="View in rythmfiddle" ng-href="/editor/#/editor/{{currentCode.id}}" data-id="{{currentCode.id}}">
View in Fiddle <i class="icon-cloud"></i>
</a>
<a id="view_in_fullscreen" class="btn" target="_blank" title="View in new tab" ng-href="/embed/#/{{currentCode.id}}" data-id="{{currentCode.id}}">
<i class="icon-folder-close-alt"></i>
</a>
<span class="btn" title="Add new template" ng-click="newFile()">
<i class="icon-plus"></i>
</span>
Expand Down
2 changes: 1 addition & 1 deletion angular-seed/app/partials/save_dialog.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="control-group">
<label class="control-label">Brief description: </label>
<div class="controls">
<input type="text" ng-model="code.desc"/>
<input type="text" ng-model="code.desc" autofocus="autofocus" ui-keypress="{enter: 'save()'}"/>
</div>
</div>
<div class="control-group">
Expand Down
2 changes: 1 addition & 1 deletion app/common/Helper.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package common;

import com.google.gson.Gson;
import com.greenlaw110.rythm.utils.S;
import org.rythmengine.utils.S;
import models.Code;

import java.util.HashMap;
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Application.java
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package controllers;

import com.google.gson.Gson;
import com.greenlaw110.rythm.utils.S;
import org.rythmengine.utils.S;
import common.CodeManager;
import common.Helper;
import models.Code;
Expand Down
Loading