-
Notifications
You must be signed in to change notification settings - Fork 31
[WIP] Create routes from the front end #24
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
Open
adou600
wants to merge
14
commits into
master
Choose a base branch
from
create-routes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
97ddd4a
create_routes parameter in the config
adou600 bf1da4a
WIP 1st functional version of create routes JS handler
adou600 7cb10a0
automatic js config for locales, routes and content prefix
adou600 c3bfd15
move CmfRoute to the CreateBundle
adou600 96c7324
list of rdf types for which to create routes
adou600 3dfb241
fix typos
adou600 59aa2c5
handle the case where new content and updated content is saved at the…
adou600 3ca8690
WIP: use configurable mapper instead of CmfRoute document to set loca…
adou600 544d7e0
cleaning and comments after createphp RdfTypeFactory refactoring
adou600 b154d18
improve error handling for frontend route creation
adou600 34115e0
various fixes after lsmith77 review
adou600 d436362
tmp fix for create.js bug
adou600 2468b8a
typos on error messages
adou600 4fdffc6
Merge master
adou600 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| jQuery(document).ready(function() { | ||
|
|
||
| (function(){ | ||
|
|
||
| var needRouteCreation = false; //internal trigger for savedentity event | ||
|
|
||
| //an entity has been saved and the response of the backend received | ||
| $('body').bind('midgardstoragesavedentity', function (event, options) { | ||
|
|
||
| //create the routes only when new content has been saved | ||
| if (!needRouteCreation || options.entity.id.indexOf(cmfCreateRoutesPrefix, 1) == 1) { | ||
| return; | ||
| } | ||
|
|
||
| var vie = options.entity.vie; | ||
|
|
||
| /** | ||
| * Common request content | ||
| */ | ||
| var trimmedSubject = options.entity.id.substr(1, options.entity.id.length - 2); | ||
| var lastSlashPos = trimmedSubject.lastIndexOf("/") + 1; | ||
| var contentName = trimmedSubject.substr(lastSlashPos, trimmedSubject.length - lastSlashPos); | ||
| var partOf = options.entity.attributes["<http://purl.org/dc/terms/partOf>"].models[0]["@subject"]; | ||
| var trimmedPartOf = partOf.substr(1, partOf.length - 2); // "/cms/content/news" | ||
| var lastSlashPos = trimmedPartOf.lastIndexOf("/") + 1; | ||
| var parentName = trimmedPartOf.substr(lastSlashPos, trimmedPartOf.length - lastSlashPos); | ||
|
|
||
| /** | ||
| * Request types | ||
| */ | ||
| var parentType = "<" + cmfCreateRouteRdfType + "/Parent" + ">"; | ||
| var nameType = "<" + cmfCreateRouteRdfType + "/Name" + ">"; | ||
| var routeContentType = "<" + cmfCreateRouteRdfType + "/RouteContent" + ">"; | ||
| var localeType = "<" + cmfCreateRouteRdfType + "/Locale" + ">"; | ||
| var partOfType = "<http://purl.org/dc/terms/partOf>"; | ||
|
|
||
| for(var i in cmfCreateLocales) { | ||
| var parentPath = cmfCreateRoutesPrefix + "/" + cmfCreateLocales[i] + "/" + parentName; | ||
|
|
||
| var routeRequest = {}; | ||
| routeRequest["@type"] = "<" + cmfCreateRouteRdfType + ">"; | ||
| routeRequest[nameType] = contentName; | ||
| routeRequest[routeContentType] = trimmedSubject; | ||
| routeRequest[partOfType] = [parentPath]; | ||
| routeRequest[localeType] = cmfCreateLocales[i]; | ||
| routeRequest[parentType] = parentPath; | ||
|
|
||
| var routeEntity = new vie.Entity(); | ||
| routeEntity.set(routeRequest); | ||
| vie.entities.add(routeEntity); | ||
| jQuery('body').midgardStorage('saveRemote', routeEntity, options); | ||
| } | ||
| }); | ||
|
|
||
| //an entity will be saved and sent to the backend | ||
| $('body').bind('midgardstoragesaveentity', function (event, options) { | ||
| //TODO: handle the case where new content and updated content is saved at the same time | ||
| needRouteCreation = options.entity.isNew(); | ||
| }); | ||
| })() | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe you should make this a list of rdf types for which to create routes, defaulting to empty array.
if i create a new simplecms document or a new block, i don't need a route for that...