diff --git a/.gitignore b/.gitignore index 3fcea8c91eaac4bfdcf8baa2d417c462ea9317a7..1eb686b8784ce5f8bfb66231606a20bef51527d7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,4 +10,5 @@ dist/html/* # Files index.html +config.php issues.md diff --git a/README.md b/README.md index b52599529253303ae79616ebd09ac5dadaff83fc..1faf661dc5f03cefa3cf7df341175b4bd32b516b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,6 @@ HD app is the magic tool that allows the Happy Dev network to thrive in a decent ## Install (Ubuntu) * `git clone --recurse-submodules https://git.happy-dev.fr/happy-dev/hd-app.git` * `cd hd-app` - * `apt install npm` * `npm install -g grunt-cli` * `npm install` diff --git a/config-sample.php b/config-sample.php new file mode 100644 index 0000000000000000000000000000000000000000..9e8c1d0e9efd95a81072d3109e49622dfb49638e --- /dev/null +++ b/config-sample.php @@ -0,0 +1,8 @@ +<?php + $dn = getenv("DN");// Domain Name of the app + $sdn = getenv("SDN");// Server Domain Name + + if ($dn === NULL) { + $dn = 'http://hd-app.local'; + $sdn = 'http://localhost:8000'; + } diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000000000000000000000000000000000000..4b044c04e07ad9a8e6e2ad869ebf37858522bf7d --- /dev/null +++ b/deploy.sh @@ -0,0 +1,9 @@ +#!/bin/bash +export DN="http://app.happy-dev.fr" +export SDN="http://hd-ldp.happy-dev.fr" +php index.php > index.html +grunt +ssh happy-dev_alex@ssh-happy-dev.alwaysdata.net "cd hd-app; rm -Rf ./*; mkdir -p src/fonts; mkdir -p dist/css;" +scp -r index.html happy-dev_alex@ssh-happy-dev.alwaysdata.net:~/hd-app/ +scp -r dist/css/ happy-dev_alex@ssh-happy-dev.alwaysdata.net:~/hd-app/dist/ +scp -r src/fonts/ happy-dev_alex@ssh-happy-dev.alwaysdata.net:~/hd-app/src/ diff --git a/index.php b/index.php index 6abe39729ab393c5c99f6a1f239c4adf2a1aeff2..c2dd5149f7ab73d2ae96b92a8619c808c180db56 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ <?php // Some useful variables $v = rand();// Used to avoid abusive caching by the browser - $dn = 'http://'. $_SERVER['HTTP_HOST']; + require_once("config.php");// Use "config-sample.php" to create your own ?> <!DOCTYPE html> <html lang="fr"> @@ -12,20 +12,14 @@ <title>Happy Dev App</title> - <!-- Stylesheets --> - <link rel="stylesheet" href="<?php echo $dn; ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" /> - <link rel="stylesheet" href="<?php echo $dn; ?>/dist/css/hd-app.css?v=<?php echo $v ?>" /> - <link rel="stylesheet" href="<?php echo $dn; ?>/node_modules/font-awesome/css/font-awesome.min.css" /> - - <!-- Javascript --> - <script type="text/javascript" src="<?php echo $dn; ?>/node_modules/jquery/dist/jquery.min.js"></script> - <script type="text/javascript" src="<?php echo $dn; ?>/node_modules/bootstrap/dist/js/bootstrap.min.js"></script> - <script type="text/javascript" src="<?php echo $dn; ?>/dist/lib/webcomponentsjs/webcomponents-loader.js"></script> - - <!-- Web components --> - <link rel="import" href="<?php echo $dn; ?>/dist/lib/ldp-display/ldp-display.html?v=<?php echo $v ?>" /> - <link rel="import" href="<?php echo $dn; ?>/dist/lib/ldp-display/ldp-router.html?v=<?php echo $v ?>" /> - <link rel="import" href="<?php echo $dn; ?>/dist/lib/xmpp-chat-component/chat-window-component.html?v=<?php echo $v ?>"> + <?php + // Prod/Dev setup + if ($dn == 'http://app.happy-dev.fr') { + require_once("src/html/dependencies-prod.php"); + } else { + require_once("src/html/dependencies-dev.php"); + } + ?> </head> <body> diff --git a/src/html/dependencies-dev.php b/src/html/dependencies-dev.php new file mode 100644 index 0000000000000000000000000000000000000000..d44471553c1ef5896286fb77fb100f35763464a5 --- /dev/null +++ b/src/html/dependencies-dev.php @@ -0,0 +1,15 @@ + <!-- Stylesheets --> + <link rel="stylesheet" href="<?php echo $dn; ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" /> + <link rel="stylesheet" href="<?php echo $dn; ?>/dist/css/hd-app.css?v=<?php echo $v ?>" /> + <link rel="stylesheet" href="<?php echo $dn; ?>/node_modules/font-awesome/css/font-awesome.min.css" /> + + <!-- Javascript --> + <script type="text/javascript" src="<?php echo $dn; ?>/node_modules/jquery/dist/jquery.min.js"></script> + <script type="text/javascript" src="<?php echo $dn; ?>/node_modules/bootstrap/dist/js/bootstrap.min.js"></script> + <script type="text/javascript" src="<?php echo $dn; ?>/dist/lib/webcomponentsjs/webcomponents-loader.js"></script> + + <!-- Web components --> + <link rel="import" href="<?php echo $dn; ?>/dist/lib/ldp-display/ldp-display.html?v=<?php echo $v ?>" /> + <link rel="import" href="<?php echo $dn; ?>/dist/lib/ldp-display/ldp-router.html?v=<?php echo $v ?>" /> + <link rel="import" href="<?php echo $dn; ?>/dist/lib/xmpp-chat-component/chat-window-component.html?v=<?php echo $v ?>"> + diff --git a/src/html/dependencies-prod.php b/src/html/dependencies-prod.php new file mode 100644 index 0000000000000000000000000000000000000000..20bbd3ea96fa523b7d45f9de5b4395b0635389c0 --- /dev/null +++ b/src/html/dependencies-prod.php @@ -0,0 +1,15 @@ + <!-- Stylesheets --> + <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous"> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.10/css/all.css" integrity="sha384-+d0P83n9kaQMCwj8F4RJB66tzIwOKmrdb46+porD/OvrJ+37WqIM7UoBtwHO6Nlg" crossorigin="anonymous"> + <link rel="stylesheet" href="<?php echo $dn; ?>/dist/css/hd-app.css?v=<?php echo $v ?>" /> + + <!-- Javascript --> + <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script> + <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.2.0/webcomponents-loader.js" integrity="sha256-fUVqCtpScUF69qkFkeuHmcShr2N2UleRQJhRG4etHds=" crossorigin="anonymous"></script> + + <!-- Web components --> + <link rel="import" href="https://cdn.happy-dev.fr/ldp-display/ldp-display.html?v=<?php echo $v ?>" /> + <link rel="import" href="https://cdn.happy-dev.fr/ldp-display/ldp-router.html?v=<?php echo $v ?>" /> + <link rel="import" href="https://cdn.happy-dev.fr/xmpp-chat-component/chat-window-component.html?v=<?php echo $v ?>"> diff --git a/src/models.py b/src/server/models.py similarity index 100% rename from src/models.py rename to src/server/models.py diff --git a/src/server/urls.py b/src/server/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..4164c20f081d06f96b5d2f7ffe0dda5f485e2c54 --- /dev/null +++ b/src/server/urls.py @@ -0,0 +1,30 @@ +"""hdappserver URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.11/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +from django.conf.urls import url, include +from django.contrib import admin +from djangoldp.views import LDPViewSet +from .models import Member, Skill, Project, Client, Cell, Channel + +urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^members/', LDPViewSet.urls(model=Member, nested_field="skills")), + url(r'^skills/', LDPViewSet.urls(model=Skill)), + url(r'^projects/', LDPViewSet.urls(model=Project, nested_field="team")), + url(r'^clients/', LDPViewSet.urls(model=Client)), + url(r'^cells/', LDPViewSet.urls(model=Cell)), + url(r'^channels/', LDPViewSet.urls(model=Channel, nested_field="members")), +] +