Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions VAGRANT.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ From the fieldpapers checkout on your host machine
*Celery logging*
`vagrant ssh -c "screen -r celery"`

"mysql --user=fieldpapers --password=w4lks fieldpapers"

3 changes: 3 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.synced_folder "./", "/usr/local/fieldpapers/", id: "vagrant-root",
owner: "vagrant",
group: "www-data",
Expand All @@ -14,6 +16,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.provider :virtualbox do |vb, override|
vb.memory = 1024
vb.cpus = 1
vb.name = "Field Papers Appliance"
override.vm.box = "precise64"
override.vm.box_url = "http://files.vagrantup.com/precise64.box"
override.vm.network :private_network, ip: "192.168.33.10"
Expand Down
7 changes: 4 additions & 3 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
- apache2
- php5
- php5-mysql
- php5-sqlite
- phpmyadmin
- build-essential
- libcairo2-dev
Expand Down Expand Up @@ -52,8 +53,8 @@
- name: Move default Apache root
action: command mv /var/www /var/www-old

- name: Symlink /var/www to /vagrant
action: command ln -s /vagrant /var/www
- name: Symlink /var/www to /usr/local/fieldpapers
action: command ln -s /usr/local/fieldpapers /var/www

- name: Make fieldpapers site
command: "{{ item }} chdir=/usr/local/fieldpapers/site"
Expand Down Expand Up @@ -91,7 +92,7 @@
- name: "Install BlobDetector from a local package instead of pip for now"
command: "python setup.py install"
args:
chdir: "/vagrant/provisioning/BlobDetector-1.0.0/"
chdir: "/usr/local/fieldpapers/provisioning/BlobDetector-1.0.0/"

- name: Install packages via pecl.
command: "pecl install {{ item }}"
Expand Down
7 changes: 7 additions & 0 deletions site/lib/lib.compose.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ function compose_from_postvars(&$dbh, $post, $user_id)
$orientation = isset($post['orientation']) ? $post['orientation'] : 'portrait';
$layout = isset($post['layout']) ? $post['layout'] : 'full-page';
$provider = $post['provider'];
$overlay = $post['overlay'];
$title = $post['atlas_title'];
$grid = filter_var($post['grid'], FILTER_VALIDATE_BOOLEAN) ? 1 : 0;
$redcross = filter_var($post['redcross'], FILTER_VALIDATE_BOOLEAN) ? 1 : 0;
Expand Down Expand Up @@ -455,6 +456,12 @@ function compose_from_postvars(&$dbh, $post, $user_id)

if($redcross)
$message['pages'][$i]['provider'] = "{$value['provider']},http://a.tiles.mapbox.com/v3/americanredcross.HAIYAN_Atlas_Bounds/{Z}/{X}/{Y}.png";

if($overlay)
$message['pages'][$i]['provider'] = "{$value['provider']},{$overlay}";



}

// Deal with WOEIDs
Expand Down
14 changes: 13 additions & 1 deletion site/templates/make-step2-geography.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@

var mbtiles_data = {$mbtiles_data|@json_encode} || null,
center = {$center|json_encode} || null,
zoom = {$zoom|json_encode} || null;
zoom = {$zoom|json_encode} || null,
zoom = {$zoom|json_encode} || null,
user_mbtiles = {$user_mbtiles|@json_encode} || null;

</script>
<script type="text/javascript" src="{$base_dir}/js/make_geography.js"></script>
<style type="text/css">
Expand Down Expand Up @@ -206,6 +209,15 @@
<option value="{$provider.0|escape}">{$provider.1|escape}</option>
{/foreach}
</select>

{if $user_mbtiles}

<select style="width: 150px; top: -8px; margin-left: 10px; position: relative;" name="overlay" onChange="setOverlayProvider(this.value);">
{foreach from=$user_mbtiles key="index" item="user_mbtiles_file"}
<option value="{$user_mbtiles_file.url|escape}">{$user_mbtiles_file.uploaded_file|escape}</option>
{/foreach}
</select>
{/if}

<span id="page_count_container">
<span id="page_count"><b>1</b></span><br>
Expand Down
4 changes: 4 additions & 0 deletions site/templates/make-step3-info.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
{if $atlas_data.clone_id}
<input type="hidden" id="clone_id" name="clone_id" value="{$atlas_data.clone_id|escape}">
{/if}

{if $atlas_data.overlay}
<input type="hidden" id="overlay" name="overlay" value="{$atlas_data.overlay|escape}">
{/if}

{if $atlas_data.refresh_id}
<input type="hidden" id="refresh_id" name="refresh_id" value="{$atlas_data.refresh_id|escape}">
Expand Down
4 changes: 4 additions & 0 deletions site/templates/make-step4-layout.html.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
{if $atlas_data.clone_id}
<input type="hidden" name="clone_id" value="{$atlas_data.clone_id|escape}">
{/if}

{if $atlas_data.overlay}
<input type="hidden" name="overlay" value="{$atlas_data.overlay|escape}">
{/if}

{if $atlas_data.refresh_id}
<input type="hidden" id="refresh_id" name="refresh_id" value="{$atlas_data.refresh_id|escape}">
Expand Down
9 changes: 9 additions & 0 deletions site/www/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
all:
mkdir -p files
chmod a+rwX files

mkdir -p files/mbtiles
chmod a+rwX files/mbtiles

mkdir -p files/prints
chmod a+rwX files/prints

mkdir -p files/scans
chmod a+rwX files/scans
23 changes: 21 additions & 2 deletions site/www/js/make_geography.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var map = null,
map_layer;
map_layer,
overlay_layer;

var paper_orientations = {"landscape": 1.50, "portrait": .75},
page_aspect_ratio = paper_orientations["landscape"],
Expand Down Expand Up @@ -40,6 +41,12 @@ function setProvider(tileURL)
map_layer.setProvider(new MM.TemplatedMapProvider(tileURL));
}

function setOverlayProvider(tileURL)
{
overlay_layer.setProvider(new MM.TemplatedMapProvider(tileURL));
map.draw();
}

function setMapHeight()
{
var map_height = window.innerHeight - document.getElementById("nav").offsetHeight - 20;
Expand Down Expand Up @@ -585,6 +592,7 @@ function initUI () {
// Map
////
var MM = com.modestmaps;
var layers = [];

if (mbtiles_data)
{
Expand All @@ -596,10 +604,21 @@ function initUI () {
}

map_layer = new MM.Layer(provider);
layers.push(map_layer);

if(user_mbtiles)
{
var overlayURL = user_mbtiles[0]["url"],
overlayProvider = new MM.TemplatedMapProvider(overlayURL);

overlay_layer = new MM.Layer(overlayProvider);
layers.push(overlay_layer);
}


setMapHeight();

map = new MM.Map("map", map_layer,null,[new MM.DragHandler(), new MM.DoubleClickHandler()]);
map = new MM.Map("map", layers, null,[new MM.DragHandler(), new MM.DoubleClickHandler()]);

if (mbtiles_data)
{
Expand Down
1 change: 1 addition & 0 deletions site/www/make-step1-search.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
// pass $error_nosearch to template

if (is_logged_in()) {

$user_mbtiles = get_mbtiles_by_user_id($context->db, $context->user['id']);

if ($user_mbtiles)
Expand Down
9 changes: 9 additions & 0 deletions site/www/make-step2-geography.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
exit();
}
}

if (is_logged_in()) {
$user_mbtiles = get_mbtiles_by_user_id($context->db, $context->user['id']);

if ($user_mbtiles)
{
$context->sm->assign('user_mbtiles', $user_mbtiles);
}
}

$context->sm->assign('providers', get_map_providers());

Expand Down
3 changes: 3 additions & 0 deletions site/www/make-step3-info.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
'private' => filter_var($_REQUEST['private'], FILTER_VALIDATE_BOOLEAN),
);

if($_POST['overlay'])
$atlas_data['provider'] = $atlas_data['provider'].','.$_POST['overlay'];

if($_POST['atlas_title'])
$atlas_data['atlas_title'] = $_POST['atlas_title'];

Expand Down
3 changes: 3 additions & 0 deletions site/www/make-step4-layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
'pages' => (is_array($_POST['pages']) ? $_POST['pages'] : array()),
'private' => filter_var($_REQUEST['private'], FILTER_VALIDATE_BOOLEAN),
);

if($_POST['overlay'])
$atlas_data['overlay'] = $_POST['overlay'];

if(isset($_POST['clone_id']) && !empty($_POST['clone_id'])){
$atlas_data['clone_id'] = trim($_POST['clone_id']);
Expand Down
4 changes: 2 additions & 2 deletions site/www/mbtiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
header('Content-Type: image/png');
echo $png_data;
} else {
header("HTTP/1.0 404 Not Found");
//header("HTTP/1.0 404 Not Found");

header('Content-Type: image/png');
echo file_get_contents('img/no-tile-here.png');
//echo file_get_contents('img/no-tile-here.png');
}

$db_mbtiles->close();
Expand Down