diff --git a/bin/_commands/choice.sh b/bin/_commands/choice.sh index 5419168..96227b3 100755 --- a/bin/_commands/choice.sh +++ b/bin/_commands/choice.sh @@ -15,11 +15,14 @@ choose() { user=${user%%/*} target=${target#*(} target=${target%)*} + target=${target#/pages} echo "Choice => $target.md for user $user" - echo cp "../content$target.md" "../content/users/$user${target%/*}/" - cp "../content$target.md" "../content/users/$user${target%/*}/" + mkdir -p "../content/users/$user${target%/*}/" + cp "../content/pages$target.md" "../content/users/$user${target%/*}/" + chmod -R g+rw "../content/users/$user${target%/*}/" + chgrp -R www-data "../content/users/$user${target%/*}/" # Delete former result files rm "$dir/*.result" diff --git a/bin/_commands/choice_test.bats b/bin/_commands/choice_test.bats index cbae495..10bd55b 100755 --- a/bin/_commands/choice_test.bats +++ b/bin/_commands/choice_test.bats @@ -1,6 +1,7 @@ #!/usr/bin/env bats setup() { + mkdir -p content/pages/test mkdir -p content/users/test } @@ -8,14 +9,14 @@ setup() { echo "--- title: Basic test --- -" > content/test.md +" > content/pages/test/hop.md echo "--- title: Basic choice test ac_choices: -- \"[abc](/home)\" -- \"[def](/test)\" -- \"[ghi](/home)\" +- \"[abc](/pages/test/home)\" +- \"[def](/pages/test/hop)\" +- \"[ghi](/pages/test/home)\" --- " > content/users/test/choice_test.md @@ -29,10 +30,10 @@ ac_choices: [ ! -e content/users/test/choice_test.md ] [ ! -e content/users/test/choice_test.choice ] [ -e content/users/test/choice_test.result ] - [ -e content/users/test/test.md ] + [ -e content/users/test/test/hop.md ] } teardown() { - rm -f content/test.md + rm -rf content/pages/test rm -rf content/users/test } diff --git a/bin/_commands/content_test.bats b/bin/_commands/content_test.bats index bf561f4..07d2e0e 100755 --- a/bin/_commands/content_test.bats +++ b/bin/_commands/content_test.bats @@ -27,4 +27,4 @@ On multiple lines" > content/users/test/content_test.content teardown() { rm -rf content/users/test -} +} \ No newline at end of file diff --git a/bin/_commands/create.sh b/bin/_commands/create.sh index eb0e5e1..63f5592 100755 --- a/bin/_commands/create.sh +++ b/bin/_commands/create.sh @@ -9,6 +9,7 @@ kind=$(cat "$dir/$file") echo "Creating content/$kind/$page" hugo --source=.. new "content/$kind/$page" +chmod -R g+rw "content/$kind/$page" +chgrp -R www-data "content/$kind/$page" -# Important to automated tests -chmod g+w "../content/$kind/$page" +./ac_route.sh "$dir/$page" _index.md diff --git a/bin/_commands/create_delete_test.bats b/bin/_commands/create_delete_test.bats index 71f70d1..62e78aa 100755 --- a/bin/_commands/create_delete_test.bats +++ b/bin/_commands/create_delete_test.bats @@ -29,4 +29,4 @@ [ ! -e content/users/create_test.delete ] [ ! -e content/users/create_test/_index.md ] [ ! -e content/users/create_test ] -} +} \ No newline at end of file diff --git a/bin/_commands/default_actions.sh b/bin/_commands/default_actions.sh index 4e2b153..b35647b 100755 --- a/bin/_commands/default_actions.sh +++ b/bin/_commands/default_actions.sh @@ -5,6 +5,7 @@ dir=$1 file=$2 +echo echo "Default actions for $dir/$file" create() { @@ -12,8 +13,15 @@ create() { for value in $values do - echo "Creating $value" - cp "../content/$value.md" "$dir/$value.md" + target=${dir%/users/*}/users/$user/${value#/pages/} + target=$(dirname "$target") + + mkdir -p "$target" + cp "../content$value.md" "$target" + chmod -R g+rw "$target" + chgrp -R www-data "$target" + + ./ac_route.sh "$target" "${value##*/}.md" done } @@ -29,6 +37,9 @@ delete() { if [ -z "${dir##*/content/users/*}" ] then + user=${dir#*/users/} + user=${user%%/*} + create delete fi diff --git a/bin/_commands/default_actions_test.bats b/bin/_commands/default_actions_test.bats index 5f2bb54..5589a19 100755 --- a/bin/_commands/default_actions_test.bats +++ b/bin/_commands/default_actions_test.bats @@ -9,33 +9,35 @@ setup() { echo "--- title: Simple link test --- -" > content/simple_link_test.md +" > content/pages/test/simple_link_test.md - cp content/simple_link_test.md content/users/test/ + mkdir content/users/test/test + cp content/pages/test/simple_link_test.md content/users/test/test - bin/ac_route.sh "$(pwd)/content" simple_link_test.md + bin/ac_route.sh "$(pwd)/content/users/test/test" simple_link_test.md - [ -e content/users/test/simple_link_test.md ] + [ -e content/users/test/test/simple_link_test.md ] } @test "Create file" { echo "--- -title: Test file to be create +title: Test file to be created --- -" > content/to_create.md +" > content/pages/test/to_create.md echo "--- title: Create test ac_create: -- to_create +- /pages/test/to_create --- -" > content/to_create_test.md +" > content/pages/test/to_create_test.md - cp content/to_create_test.md content/users/test/ + mkdir content/users/test/test + cp content/pages/test/to_create_test.md content/users/test/test - bin/ac_route.sh "$(pwd)/content/users/test" to_create_test.md + bin/ac_route.sh "$(pwd)/content/users/test/test" to_create_test.md - [ -e content/users/test/to_create.md ] + [ -e content/users/test/test/to_create.md ] } @test "Delete file" { @@ -67,7 +69,6 @@ teardown() { rm -f content/test.md rm -rf content/pages/test rm -rf content/users/test - rm -f content/simple_link_test.md rm -f content/to_create_test.md rm -f content/to_delete_test.md rm -f content/to_create.md diff --git a/bin/acoeur.conf b/bin/acoeur.conf index 5fce763..bd003f7 100644 --- a/bin/acoeur.conf +++ b/bin/acoeur.conf @@ -1,13 +1,11 @@ - ServerName acoeur.localhost - ServerAlias acoeur acoeur.acoeuro.com + ServerName acoeur DocumentRoot /var/simpleWeb/apps/acoeur/public - ServerName edit.acoeur.localhost - ServerAlias edit.acoeur edit.acoeur.acoeuro.com + ServerName edit.acoeur ServerSignature Off Header add Access-Control-Allow-Origin "*" Header add Access-Control-Allow-Methods "HEAD, GET, POST, PUT, OPTIONS, DELETE" diff --git a/themes/acoeur/archetypes/users/_index.md b/themes/acoeur/archetypes/users/_index.md index b5eef3a..3825d8d 100644 --- a/themes/acoeur/archetypes/users/_index.md +++ b/themes/acoeur/archetypes/users/_index.md @@ -3,7 +3,7 @@ title: Nouvel utilisateur description: Court texte date: {{ .Date }} ac_create: -- /pages/1er-quizz/_index +- /pages/1er-quiz/_index --- Texte