Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to generated views to use 'relativeUrlRoot' #594

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion gen/scaffold/views/ejs/add.html.ejs.ejs
@@ -1,5 +1,5 @@
<div class="hero-unit">
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>" method="POST">
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="<@= geddy.config.relativeUrlRoot@>/<%=names.filename.plural %>" method="POST">
<fieldset>
<legend>Create a new <%= names.constructor.singular %></legend>
<@ if(params.errors) { @>
Expand Down
4 changes: 2 additions & 2 deletions gen/scaffold/views/ejs/edit.html.ejs.ejs
@@ -1,5 +1,5 @@
<div class="hero-unit">
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="/<%= names.filename.plural %>/<@= params.id @>?_method=PUT" method="POST">
<form id="<%= names.property.singular %>-form" class="form-horizontal" action="<@= geddy.config.relativeUrlRoot@>/<%= names.filename.plural %>/<@= params.id @>?_method=PUT" method="POST">
<fieldset>
<legend>Update this <%= names.constructor.singular %></legend>
<@ if(params.errors) { @>
Expand All @@ -16,7 +16,7 @@

<div class="form-actions">
<@- contentTag('input', 'Save', {type: 'submit', class: 'btn btn-primary'}) @>
<@- contentTag('button', 'Remove', {type: 'submit', formaction: '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'}) @>
<@- contentTag('button', 'Remove', {type: 'submit', formaction: geddy.config.relativeUrlRoot + '/<%= names.filename.plural %>/' + params.id + '?_method=DELETE', formmethod: 'POST', class: 'btn btn-danger'}) @>
</div>
</fieldset>
</form>
Expand Down
4 changes: 2 additions & 2 deletions gen/scaffold/views/ejs/index.html.ejs.ejs
@@ -1,14 +1,14 @@
<div class="hero-unit">
<h2>All <%= names.constructor.plural %></h2>
<@- linkTo('Create a new <%= names.constructor.singular %>', add<%= names.constructor.singular %>Path, {class: 'btn pull-right'}); @>
<@- linkTo('Create a new <%= names.constructor.singular %>', geddy.config.relativeUrlRoot + add<%= names.constructor.singular %>Path, {class: 'btn pull-right'}); @>
</div>

<div id="<%= names.property.plural %>-list">
<@ if (<%= names.property.plural %>) { @>
<@ for (var i = 0, ii = <%= names.property.plural %>.length; i < ii; i++) { @>
<div class="row list-item" id="<%= names.property.singular %>-<@= <%= names.property.plural %>[i].id; @>">
<div class="span8">
<h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name || "id" %>, <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
<h3><@- linkTo(<%= names.property.plural %>[i].<%= properties['default'].name || "id" %>, geddy.config.relativeUrlRoot + <%= names.property.singular %>Path(<%= names.property.plural %>[i].id)); @></h3>
</div>
<div class="span4">
<h3><i class="icon-list-alt"></i><@= <%= names.property.plural %>[i].id; @></h3>
Expand Down
4 changes: 2 additions & 2 deletions gen/scaffold/views/ejs/show.html.ejs.ejs
@@ -1,7 +1,7 @@
<div class="hero-unit">
<h2 class="<%= properties['default'].name || "id" %>"><@= <%= names.property.singular %>.<%= properties['default'].name || "id" %> @></h2>
<@- linkTo('Edit this <%= names.property.singular %>', edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'}); @>
<@- linkTo('Back to list', <%= names.property.singular %>Path(''), {class: 'btn pull-right'}); @>
<@- linkTo('Edit this <%= names.property.singular %>', geddy.config.relativeUrlRoot + edit<%= names.constructor.singular %>Path(params.id), {class: 'btn pull-right'}); @>
<@- linkTo('Back to list', geddy.config.relativeUrlRoot + <%= names.property.singular %>Path(''), {class: 'btn pull-right'}); @>
</div>

<h2><%= names.constructor.singular %> Properties</h2>
Expand Down
1 change: 1 addition & 0 deletions lib/base_config.js
Expand Up @@ -91,6 +91,7 @@ config = {
, hostname: null
// Used in helpers
, fullHostname: null
, relativeUrlRoot: ''
// Switch for making before/after filters compatible with
// Connect middleware
, connectCompatibility: false
Expand Down
3 changes: 2 additions & 1 deletion lib/controller/base_controller.js
Expand Up @@ -558,7 +558,8 @@ controller.BaseController.prototype = new (function () {
, id = target.id;

contr = utils.string.decamelize(contr);
url = '/' + contr;
url = geddy.config.relativeUrlRoot;
url += '/' + contr;
url += act ? '/' + act : '';
url += id ? '/' + id : '';
if (ext) {
Expand Down