Skip to content

Commit

Permalink
phonegap build tool (see #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Jan 5, 2017
1 parent 362517a commit 65b49e6
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ htdocs
lib
themes.css
*.appcache
.wq-pgb
8 changes: 8 additions & 0 deletions app/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "{{ app_id }}"
version = "{% templatetag openvariable %}version{% templatetag closevariable %}" >
<name>{{ project_name }} Project</name>
<description>{{ project_name }} Project</description>
</widget>
54 changes: 54 additions & 0 deletions app/index-phonegap.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html>
<head>
<title>{{ project_name }} Project</title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=yes" />
<link rel="stylesheet" href="css/{{ project_name }}.css">
<script src="cordova.js"></script>
<script src="js/lib/require.js"></script>
<script>
function getBaseUrl() {
var baseurl = window.location.pathname.replace("index.html",'');
baseurl = baseurl.replace(/\/$/,'');
if (baseurl == 'www') {
// Windows
baseurl = '/www';
}
return baseurl;
}

require.config({
'config': {
'{{ project_name }}/config': {
'router': {
'base_url': getBaseUrl()
},
'store': {
'service': 'https://{{ domain }}',
'defaults': {'format': 'json'}
},
}
}
});
require(['js/{{ project_name }}'], function() {
require(['{{ project_name }}/main', 'wq/app'], function(ready, app) {
ready.then(function() {
app.nav('');
});
});
});
</script>
</head>
<body>
<p style='text-align: center'>
<a href="./">
<img src='images/icon-512.png' style='max-width: 80%;'>
</a>
</p>
<p class="footer">
{{ project_name }} v{% templatetag openvariable %}version{% templatetag closevariable %}
&bull;
Powered by <a href="https://wq.io/">wq</a>
</p>
</body>
</html>
14 changes: 10 additions & 4 deletions app/js/project_name/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
define(["data/config", "data/templates", "data/version"],
function(config, templates, version) {
define(["data/config", "data/templates", "data/version", "module"],
function(config, templates, version, module) {

var overrides = module.config();

config.router = {
'base_url': ''
}
};

config.template = {
'templates': templates,
Expand All @@ -15,7 +17,7 @@ config.template = {
config.store = {
'service': config.router.base_url,
'defaults': {'format': 'json'}
}
};

config.map = {
'bounds': [[44.7, -93.6], [45.2, -92.8]]
Expand All @@ -28,6 +30,10 @@ config.transitions = {
'save': "flip"
};

for (var key in overrides) {
config[key] = overrides[key];
}

return config;

});
4 changes: 3 additions & 1 deletion app/js/project_name/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ app.use(photos);

config.presync = presync;
config.postsync = postsync;
app.init(config).then(function() {
var ready = app.init(config).then(function() {
app.jqmInit();
app.prefetchAll();
});
Expand All @@ -28,4 +28,6 @@ function postsync(items) {
app.syncRefresh(items);
}

return ready;

});
7 changes: 7 additions & 0 deletions app/wq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,10 @@ appcache:
- "http://*"
- "https://*"
fallback: []

# Compile with PhoneGap Build
phonegap:
source: ../htdocs/
pgb_directory: ../.wq-pgb
config_xml: config.xml
index_html: index-phonegap.html
2 changes: 1 addition & 1 deletion conf/project_name.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Apache configuration for {{ project_name }}
<VirtualHost *:80>
ServerName {{ project_name }}
ServerName {{ domain }}
DocumentRoot {{ project_directory }}/htdocs/

<Directory {{ project_directory }}/htdocs/>
Expand Down
2 changes: 1 addition & 1 deletion db/project_name/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# wq: SECRET_KEY and DEBUG are defined in local_settings.py

ALLOWED_HOSTS = ["{{ project_name }}"]
ALLOWED_HOSTS = ["{{ domain }}"]


# Application definition
Expand Down
5 changes: 5 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ mv -i htdocs-build/ htdocs;

# Restart Django
touch db/{{project_name}}/wsgi.py

# Build PhoneGap application
cd app;
wq phonegap $1
cd ../;
6 changes: 5 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ <h1>{{ project_name }} Project</h1>
hardcoded list of links (rather than the default pages list) -->
{% verbatim %}{{#pages}}
<li><a href="{{rt}}/{{url}}{{#list}}/{{/list}}">{{name}} {{#list}}list{{/list}}</a></li>
{{/pages}}{% endverbatim %}
{{/pages}}
{{^pages}}{{#page_config.pages}}
<li><a href="{{rt}}/{{url}}{{#list}}/{{/list}}">{{name}} {{#list}}list{{/list}}</a></li>
{{/page_config.pages}}{{/pages}}
{% endverbatim %}
</ul>
</div>
<p class="footer">
Expand Down

0 comments on commit 65b49e6

Please sign in to comment.