Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorAlec Leamas <leamas.alec@gmail.com>2011-01-10 01:31:55 +0300
committerAlec Leamas <leamas.alec@gmail.com>2011-01-10 01:38:03 +0300
commite01fb62eeb5ee84200ba93dd7cc543c0d25d2dc4 (patch)
tree1b1936ddac3367e0c5cbca5f53d2d64cf7fd4933 /script
parent18827b40d1f5dcb3322fca32075bc8a98ca8a2dc (diff)
Expose and refer to assets on the sub_uri.
When using sub-uri, create a symlink in public/ making the assets available at the sub-uri. Modify environment.rb so that asset paths refers to this sub-uri path. Closes http://bugs.joindiaspora.com/issues/391 and http://bugs.joindiaspora.com/issues/737 when application mounted on suburi (i. e., prev patch)
Diffstat (limited to 'script')
-rwxr-xr-xscript/get_env.sh26
-rwxr-xr-xscript/server17
2 files changed, 39 insertions, 4 deletions
diff --git a/script/get_env.sh b/script/get_env.sh
new file mode 100755
index 000000000..83c4e0e4a
--- /dev/null
+++ b/script/get_env.sh
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Get value from AppConfig
+#
+# Usage get_env [key ...]
+
+path=$( readlink -fn $0) && cd $(dirname $path)/.. || exit 2
+
+size=0
+size=$( wc tmp/environment 2>/dev/null | awk '{print $1}') || :
+if [[ "$size" = "0" || tmp/environment -ot config/app_config.yml ]]
+then
+ ruby > tmp/environment << 'EOT'
+ require File.join('config', 'environment.rb')
+ AppConfig.config_vars.each { |key, value|
+ puts key.to_s + "\t" + value.to_s
+ }
+ puts "pod_uri.host\t" + AppConfig[:pod_uri].host.to_s
+ puts "pod_uri.path\t" + AppConfig[:pod_uri].path.to_s
+ puts "pod_uri.port\t" + AppConfig[:pod_uri].port.to_s
+EOT
+fi
+
+for key in $@; do
+ awk -v key=$key '{ if ($1 == key ) print $2 }' < tmp/environment
+done
diff --git a/script/server b/script/server
index b20e0d59c..5fea4a2cf 100755
--- a/script/server
+++ b/script/server
@@ -9,12 +9,22 @@ OS=`uname -s`
[ -e config/server.sh ] && source config/server.sh
+function init_suburi_assets
+# fix a symlink corresponding to sub-uri
+{
+ find public -maxdepth 1 -type l -delete
+ sub_uri=$(./script/get_env.sh pod_uri.path)
+ if [ -n "$sub_uri" -a "$sub_uri" != "/" ]; then
+ cd public; ln -sf . ${sub_uri##/}; cd ..
+ fi
+}
+
function init_public
# Create all dynamically generated files in public/ folder
{
bundle exec thin \
- -d --pid log/thin.pid --address localhost --port $THIN_PORT \
- start
+ -d --pid log/thin.pid --address localhost --port $THIN_PORT \
+ start
for ((i = 0; i < 30; i += 1)) do
sleep 2
wget -q -O tmp/server.html http://localhost:$THIN_PORT && \
@@ -107,8 +117,6 @@ if [ -n "$services" ]; then
exit 64
fi
-
-
# Check if Mongo is running
if ! ps ax | grep -v grep | grep mongod >/dev/null
then
@@ -140,6 +148,7 @@ if [ ! -e 'public/stylesheets/application.css' ]; then
exit 66
fi
+[ -w public ] && init_suburi_assets
mkdir -p -v log/thin/
bundle exec ruby ./script/websocket_server.rb&