Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Fixed #362: support for app-type bare #382

Merged
merged 2 commits into from
Feb 24, 2015
Merged
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: 1 addition & 1 deletion README.mdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Download the [ml](https://github.com/marklogic/roxy/raw/master/ml) file
1. Open a command prompt in the root folder of Roxy.
2. Run ml init to create sample configuration files.
*You must specify the --server-version option with a value of 4, 5, 6 or 7*.
*You must specify the --app-type with a value or rest, hybrid, or mvc*.
*You must specify the --app-type with a value or bare, rest, hybrid, or mvc*.

`$ ml init app-name --server-version=7 --app-type=rest`
3. Modify deploy/build.properties with your application's settings.
Expand Down
1 change: 1 addition & 0 deletions deploy/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ group=Default

#
# The type of application. Choices are:
# bare: a bare Roxy app project
# mvc: a normal, XQuery-based Roxy MVC app
# rest: an app based on the ML6 REST API
# hybrid: an app that uses Roxy rewriting and the ML6 REST API
Expand Down
10 changes: 7 additions & 3 deletions deploy/lib/server_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,13 @@ def self.init
properties_file.gsub!(/rewrite-resolves-globally=/, "rewrite-resolves-globally=true")
end

# rest applications don't use Roxy's MVC structure, so they can use MarkLogic's rewriter and error handler
if app_type == "rest"
# ML8 rest uses the new native rewriter
if app_type == "bare"
# bare applications don't use rewriter and error handler
properties_file.gsub!(/url-rewriter=\/roxy\/rewrite.xqy/, "url-rewriter=")
properties_file.gsub!(/error-handler=\/roxy\/error.xqy/, "error-handler=")
elsif app_type == "rest"
# rest applications don't use Roxy's MVC structure, so they can use MarkLogic's rewriter and error handler
# Note: ML8 rest uses the new native rewriter
rewriter_name = (server_version == "8") ? "rewriter.xml" : "rewriter.xqy"
properties_file.gsub!(/url-rewriter=\/roxy\/rewrite.xqy/, "url-rewriter=/MarkLogic/rest-api/" + rewriter_name)
properties_file.gsub!(/error-handler=\/roxy\/error.xqy/, "error-handler=/MarkLogic/rest-api/error-handler.xqy")
Expand Down
1 change: 1 addition & 0 deletions deploy/sample/build.sample.properties
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ appuser-password=random

#
# The type of application. Choices are:
# bare: a bare Roxy app project
# mvc: a normal, XQuery-based Roxy MVC app
# rest: an app based on the ML6 REST API
# hybrid: an app that uses Roxy rewriting and the ML6 REST API
Expand Down
1 change: 1 addition & 0 deletions deploy/test/data/ml7-properties/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ appuser-password=Z:S1P%c9%afEqJUZu)UA

#
# The type of application. Choices are:
# bare: a bare Roxy app project
# mvc: a normal, XQuery-based Roxy MVC app
# rest: an app based on the ML6 REST API
# hybrid: an app that uses Roxy rewriting and the ML6 REST API
Expand Down
1 change: 1 addition & 0 deletions deploy/test/data/ml7-properties/default.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ xquery.dir=${basedir}/src
group=Default
#
# The type of application. Choices are:
# bare: a bare Roxy app project
# mvc: a normal, XQuery-based Roxy MVC app
# rest: an app based on the ML6 REST API
# hybrid: an app that uses Roxy rewriting and the ML6 REST API
Expand Down
16 changes: 8 additions & 8 deletions ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ hash ruby 2>&- || { echo >&2 "Ruby is required to run the ml scripts."; exit 1;

usage()
{
printf "Usage: ml new app-name --server-version=[version-number] [--branch=branch] [--app-type=mvc|hybrid|rest] [--git]\n
printf "Usage: ml new app-name --server-version=[version-number] [--branch=branch] [--app-type=bare|mvc|hybrid|rest] [--git]\n
use --git to automatically configure a git repo
use --branch to specify the GitHub branch of the Roxy project your project
will be based on (master, dev)
use --app-type to specify the project type:
bare: a bare Roxy project
mvc: a Roxy MVC project
rest: a MarkLogic REST API project
hybrid: a hybrid of both types
hybrid: a hybrid of MVC and REST types
use --force to force installation into an existing directory\n"
}

Expand Down Expand Up @@ -89,9 +90,9 @@ then
exit 1
fi

if [ "$APPTYPE" != "mvc" ] && [ "$APPTYPE" != "rest" ] && [ "$APPTYPE" != "hybrid" ]
if [ "$APPTYPE" != "bare" ] && [ "$APPTYPE" != "mvc" ] && [ "$APPTYPE" != "rest" ] && [ "$APPTYPE" != "hybrid" ]
then
printf "\nValid values for app-type are mvc, rest and hybrid. Aborting\n"
printf "\nValid values for app-type are bare, mvc, rest and hybrid. Aborting\n"
exit 1
fi

Expand All @@ -107,12 +108,11 @@ then

pushd ${app_name} > /dev/null || exit 1
rm -rf .git* || exit 1
if [ "$APPTYPE" = "rest" ]
if [ "$APPTYPE" != "mvc" ] && [ "$APPTYPE" != "hybrid" ]
then
# For a REST application, we won't be using the MVC code. Remove it.
# mvc and hybrid apps will use it.
# For non-MVC applications, we won't be using the MVC code. Remove it.
rm -rf src/* || exit 1
printf "\nNo initial source code is provided for REST apps. You can copy code from Application Builder under the source directory.\n"
printf "\nNo initial source code is provided for non-MVC apps. You can capture code from a REST application, or add your own code.\n"
fi

./ml init ${app_name} ${@} || exit 1
Expand Down
11 changes: 5 additions & 6 deletions ml.bat
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ if EXIST %app_name% GOTO alreadyexists

:skip_already_exists

if not "%APPTYPE%"=="mvc" if not "%APPTYPE%"=="rest" if not "%APPTYPE%"=="hybrid" (
echo Valid values for app-type are mvc, rest and hybrid. Aborting.
if not "%APPTYPE%"=="bare" if not "%APPTYPE%"=="mvc" if not "%APPTYPE%"=="rest" if not "%APPTYPE%"=="hybrid" (
echo Valid values for app-type are bare, mvc, rest and hybrid. Aborting.
exit /b
)

Expand All @@ -94,13 +94,12 @@ pushd %app_name%
rmdir /Q /S .git
del /F /Q .gitignore

if "%APPTYPE%"=="rest" (
REM For a REST application, we won't be using the MVC code. Remove it.
REM mvc and hybrid apps will use it.
if not "%APPTYPE%"=="mvc" if not "%APPTYPE%"=="hybrid" (
REM For non-MVC applications, we won't be using the MVC code. Remove it.
rmdir /S /Q src
mkdir src
echo.
echo No initial source code is provided for REST apps. You can copy code from Application Builder under the source directory.
echo No initial source code is provided for non-MVC apps. You can capture code from a REST application, or add your own code.
)

for /f "tokens=1-2*" %%a in ("%*") do (
Expand Down