Skip to content

Commit

Permalink
Merge pull request #60 from oetiker/qx6
Browse files Browse the repository at this point in the history
Make CallBackery work with qooxdoo 6 and the new compiler
  • Loading branch information
oetiker authored Oct 17, 2019
2 parents f9a9177 + 0e2bafc commit 2530467
Show file tree
Hide file tree
Showing 19 changed files with 262 additions and 160 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ nytprof.out
*.o
*.bs
thirdparty/
frontend/compiled/
t/callbackery.cfg.secret
my-call-backery-app/
*.gz
*.tar
dist.sh
t/callbackery.cfg.secret
*~
*~
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,24 @@ sudo: false
language: perl

perl:
- "5.22"
- "5.24"
- "5.26"
- "5.28"

before_install:
- cpanm --notest
Devel::Cover::Report::Coveralls
- nvm install 10
- nvm use 10

script:
- cover -test -report coveralls
- perl Makefile.PL
- make thirdparty
- make
- perl -I./thirdparty/lib/perl5/ -I./lib thirdparty/bin/mojo generate callbackery_app

- perl -I./thirdparty/lib/perl5/ -I./lib thirdparty/bin/mojo generate callbackery_app
- cd my-call-backery-app
- ./configure
# - curl https://cpanmin.us | PERL_CPANM_HOME=`pwd`/thirdparty perl - -q --notest --local-lib `pwd`/thirdparty --save-dists `pwd`/thirdparty --force `pwd`/..
# - make

5 changes: 5 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.19.0 2019-10-17 16:51:43 +0200 Tobias Oetiker <[email protected]>

- make callbackery work with qx6 and the new node based qooxdoo compiler
get the gooddies by running the generator to creat a new app.

0.18.2 2019-09-10 15:14:45 +0200 Tobias Oetiker <[email protected]>

- added french translation
Expand Down
7 changes: 6 additions & 1 deletion lib/CallBackery.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use CallBackery::Plugin::Doc;
use CallBackery::Database;
use CallBackery::User;

our $VERSION = '0.18.2';
our $VERSION = '0.19.0';

use Mojo::Base 'Mojolicious';

Expand Down Expand Up @@ -134,6 +134,10 @@ sub startup {
$app->log->handle($file);
}

unshift @{$app->static->paths},
$app->home->rel_file('frontend').'/compiled/source/'
if $app->mode eq 'development'; # Router

# properly figure your own path when running under fastcgi
$app->hook( before_dispatch => sub {
my $c = shift;
Expand Down Expand Up @@ -163,6 +167,7 @@ sub startup {
}

$app->secrets([ path($app->config->secretFile)->slurp ]);


my $routes = $app->routes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ qx.Class.define("callbackery.ui.Login", {

construct : function() {
this.base(arguments, this.tr("Login"));
this.__iframe = this.__ensureIframe();
// some browsers will be so nice to save the
// content of the form elements if they appear inside a form AND
// the form has a name (firefox comes to mind).
Expand Down Expand Up @@ -65,17 +66,17 @@ qx.Class.define("callbackery.ui.Login", {
});
}

if (! cfg.hide_password) {
if (! cfg.hide_password) {
this.add(new qx.ui.basic.Image("icon/64/status/dialog-password.png").set({
alignY : 'top',
alignX : 'right'
alignY : 'top',
alignX : 'right'
}),
{
row : 2,
column : 0,
rowSpan : 2
row : 2,
column : 0,
rowSpan : 2
});
}
}

this.add(new qx.ui.basic.Label(this.tr("User")), {
row : 2,
Expand All @@ -91,11 +92,11 @@ qx.Class.define("callbackery.ui.Login", {
column : 2
});

var login;
if (! cfg.hide_password) {
var login;
if (! cfg.hide_password) {
this.add(new qx.ui.basic.Label(this.tr("Password")), {
row : 3,
column : 1
column : 1
});

var password = new qx.ui.form.PasswordField();
Expand All @@ -104,13 +105,13 @@ qx.Class.define("callbackery.ui.Login", {

this.add(password, {
row : 3,
column : 2
column : 2
});
login = new qx.ui.form.Button(this.tr("Login"), "icon/16/actions/dialog-ok.png");
}
else {
}
else {
login = new qx.ui.form.Button(this.tr("OK"), "icon/16/actions/dialog-ok.png");
}
}

login.set({
marginTop : 6,
Expand All @@ -125,24 +126,24 @@ qx.Class.define("callbackery.ui.Login", {
});

if ( cfg.company_name && !cfg.hide_company){
var who = '';
var who = '';
if (cfg.company_url){
who += '<a href="' + cfg.company_url + '" style="color: #444;" target="_blank">' + cfg.company_name + '</a>';
}
else {
who += cfg.company_name;
}
}
if (! cfg.hide_release) {
if (! cfg.hide_release) {
this.add(new qx.ui.basic.Label(this.tr('release %1, %2 by %3','#VERSION#','#DATE#',who)).set({
textColor : '#444',
rich : true
rich : true
}), {
row : 5,
column : 0,
colSpan: 3
row : 5,
column : 0,
colSpan: 3
});
}
}

this.addListener('keyup', function(e) {
if (e.getKeyIdentifier() == 'Enter') {
Expand All @@ -155,14 +156,14 @@ qx.Class.define("callbackery.ui.Login", {

login.addListener("execute", function(e) {
this.setEnabled(false);
var id = this.__getIframe();
var doc = this.__getIframeDocument();
// save the username and password to our hidden iframe form
id.getElementById("cbUsername").value = username.getValue();
var passwordValue;
if (! cfg.hide_password) {
passwordValue = password.getValue();
id.getElementById("cbPassword").value = passwordValue;
}
doc.getElementById("cbUsername").value = username.getValue();
var passwordValue;
if (! cfg.hide_password) {
passwordValue = password.getValue();
doc.getElementById("cbPassword").value = passwordValue;
}
rpc.callAsync(qx.lang.Function.bind(this.__loginHandler, this), 'login',
username.getValue(),
passwordValue
Expand All @@ -171,20 +172,20 @@ qx.Class.define("callbackery.ui.Login", {
this);

this.addListener('appear', function() {
if (! cfg.hide_password) {
password.setValue('');
}
if (! cfg.hide_password) {
password.setValue('');
}
this.setEnabled(true);
if (username.getValue()){
username.set({
enabled: false,
readOnly: true,
focusable: false
});
if (! cfg.hide_password) {
if (! cfg.hide_password) {
password.focus();
password.activate();
}
}
}
else {
username.focus();
Expand All @@ -207,15 +208,28 @@ qx.Class.define("callbackery.ui.Login", {
* @param exc {Exception} any error found during the login process.
* @return {void}
*/
__getIframe: function(){
__iframe: null,
__ensureIframe: function(){
var iframe = document.getElementById("cbLoginIframe");
if (!iframe) {
iframe = qx.dom.Element.create('iframe',{
id: "cbLoginIframe",
src: "login",
style: "width:0px;height:0px;border:0px;"
});
document.body.appendChild(iframe);
}
return iframe;
},
__getIframeDocument: function(){
var iframe = this.__iframe;
return iframe.contentWindow ? iframe.contentWindow.document : iframe.contentDocument;
},
__loginHandler : function(ret, exc) {
if (exc == null) {
if (qx.lang.Type.isObject(ret) && ret.sessionCookie) {
// submit the iframe form to trigger the browser to save the password
this.__getIframe().getElementById('cbLoginForm').submit();
this.__getIframeDocument().getElementById('cbLoginForm').submit();
this.fireDataEvent('login', ret);
this.close();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/Mojolicious/Command/Author/generate/callbackery_app.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ EOF
'frontend/Makefile.am' => 'frontend/Makefile.am',
'frontend/Manifest.json' => 'frontend/Manifest.json',
'frontend/config.json' => 'frontend/config.json',
'frontend/compile.json' => 'frontend/compile.json',
'frontend/compile.js' => 'frontend/compile.js',
'frontend/package.json' => 'frontend/package.json',
'frontend/source/class/app/Application.js' => 'frontend/source/class/'.$qxclass.'/Application.js',
'frontend/source/class/app/__init__.js' => 'frontend/source/class/'.$qxclass.'/__init__.js',
'frontend/source/class/app/theme/Theme.js' => 'frontend/source/class/'.$qxclass.'/theme/Theme.js',
'frontend/source/index.html' => 'frontend/source/index.html',
't/basic.t' => 't/basic.t',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ thirdparty/*
Build.bat
.last_cover_stats
Makefile
Makefile.in
Makefile.old
MANIFEST.bak
/META.yml
Expand All @@ -26,5 +27,6 @@ nytprof.out
*.bs
/_eumm/
public/
config.*
/config.*
etc/*.cfg
/frontend/compiled/
45 changes: 24 additions & 21 deletions lib/Mojolicious/Command/Author/generate/callbackery_app/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,49 @@
AUTOMAKE_OPTIONS = foreign


SUBDIRS = thirdparty lib etc frontend bin
SUBDIRS = bin lib thirdparty etc frontend

PUB := $(shell find public -type d -name ".??*" -prune -o -not -name ".*" -a -not -name "*~" -a -not -name "*.tmp" -a -type f -print )
BIN = bin/$(MJ_SCRIPT).pl

PUB := $(shell find public -type d -name ".??*" -prune -o -not -name ".*" -a -not -name "*~" -a -not -name "*.tmp" -a -type f -print )
TEMPL := $(shell test -d templates && find templates -type f -name "*.ep")
SHARE := $(shell test -d share && find share -type f -name "*.po")
SHARE := $(shell test -d share && find share -type f -name "*")

PERLTESTS := $(shell find t -name "*.t")
PM := $(shell find lib -name "*.pm")

THIRDPARTY_DIR := $(shell pwd)/thirdparty

EXTRA_DIST = VERSION PERL_MODULES COPYRIGHT LICENSE CHANGES AUTHORS bootstrap $(PUB) \
$(wildcard t/*.t) $(POD) $(TEMPL) $(PERLTESTS) $(SHARE)

EXTRA_DIST = VERSION PERL_MODULES COPYRIGHT LICENSE CHANGES AUTHORS bootstrap $(PUB) $(wildcard t/*.t) $(BIN) $(POD) $(TEMPL) $(PERLTESTS) Dockerfile $(SHARE) share/po/messages.po

YEAR := $(shell date +%Y)
DATE := $(shell date +%Y-%m-%d)

datadir = $(prefix)
nobase_data_DATA = $(PUB) $(TEMPL) $(SHARE)

all-local:
$(GMAKE) public/script/$(QX_CLASS).js

README COPYRIGHT: VERSION
$(PERL) -i -p -e 's/(#VERSION#|\d+\.\d+\.\d+[^.\s]*)/$(PACKAGE_VERSION)/g;s/(#YEAR#|20[1-4]\d)/$(YEAR)/g;s/(#DATE#|20[1-9]\d-[01]\d-[0-3]\d)/$(DATE)/g;' $@
README.md COPYRIGHT: VERSION
$(PERL) -i -p -e 's/(#VERSION#|\d+\.\d+\.\d+[^.\s]*)/$(PACKAGE_VERSION)/g;s/(#YEAR#|20[1-9]\d)/$(YEAR)/g;s/(#DATE#|20[1-9]\d-[01]\d-[0-3]\d)/$(DATE)/g;' $@

dist-hook:
$(PERL) -i -p -e 's/#VERSION#/$(PACKAGE_VERSION)/g;s/#YEAR#/$(YEAR)/g;s/#DATE#/$(DATE)/g;' $(distdir)/public/index.html $(distdir)/public/script/$(QX_CLASS).js
$(PERL) -i -p -e 's/#VERSION#/$(PACKAGE_VERSION)/g;s/#YEAR#/$(YEAR)/g;s/#DATE#/$(DATE)/g;' $(distdir)/public/$(QX_CLASS)/*.js
$(PERL) -i -p -e 's/\$$VERSION\s*=\s*".+?";/\$$VERSION = "$(PACKAGE_VERSION)";/;' $(distdir)/lib/$(MJ_CLASS).pm

test:
$(PERL) "-MExtUtils::Command::MM" "-e" "test_harness(0, 'lib','thirdparty/lib/perl5')" t/*.t
install-exec-hook:
[ "$(PERL5LIB)" == "" ] || cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# PERL5LIB}{use lib qw($(PERL5LIB)); # PERL5LIB}' $(BIN) || true
cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# LIBDIR}{use lib qw($(libdir)); # LIBDIR}' $(BIN)
cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN)

all-local: share/messages.pot

if BUILD_QOOXDOO_APP
clean-local:
rm share/messages.pot

CALLBACKERY_PATH := $(shell PERL5LIB=lib:$(PERL5LIB):thirdparty/lib/perl5 $(PERL) -e 'use File::Basename;use Cwd qw(realpath); eval { require CallBackery }; print !$$@ ? realpath(dirname($$INC{q{CallBackery/Config.pm}}).q{/qooxdoo}) : "CALLBACKERY_NOT_FOUND" ' )
share/messages.pot: $(PM)
mkdir -p share
$(XGETTEXT) --language=perl --package-name=$(PACKAGE) --package-version=$(VERSION) --from-code=UTF-8 --keyword=trm:1 --output=share/messages.pot $(PM)
for lang in share/*.po; do \
$(MSGMERGE) -U $$lang share/messages.pot; \
done

public/script/$(QX_CLASS).js: $(shell find frontend/source $(CALLBACKERY_PATH) -type f ) frontend/config.json config.status
cd frontend && $(QOOXDOO_PATH)/tool/bin/generator.py -m QOOXDOO_PATH:$(QOOXDOO_PATH) -m CALLBACKERY_PATH:$(CALLBACKERY_PATH) -m CACHE:./cache -m BUILD_PATH:../public build

endif
test:
prove -w
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[email protected]
Mojo::[email protected]
PPI
% my $p = shift;
% use CallBackery;
CallBackery@<%= $CallBackery::VERSION %>
Mojo::SQLite
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
% my $p = shift;
#!/bin/sh
export QX_SRC_MODE=1
# relative to the application home
export QX_SRC_PATH=frontend/source
export MOJO_MODE=development
export MOJO_LOG_LEVEL=debug
exec ./<%= $p->{name} %>.pl prefork --listen 'http://*:<%= int(rand()*5000+3024) %>'
exec `dirname $0`/<%= $p->{name} %>.pl prefork --listen 'http://*:<%= int(rand()*5000+3024) %>'
Loading

0 comments on commit 2530467

Please sign in to comment.