skybrud / skybrud.umbraco.spa Goto Github PK
View Code? Open in Web Editor NEWWork in progress...
License: MIT License
Work in progress...
License: MIT License
When getting the SpaDataModel
from the micro cache, relevant properties of the current SpaRequest
aren't populated - eg.:
SpaRequest.Content
SpaRequest.ContentModel
SpaRequest.Site
SpaRequest.SiteModel
When you request the GetData api for a route that Umbraco doesn't know about we return the 404 page, and return http statuscode 404 - along with the full json response for site, nav, etc.
However it seems the 404 statuscode is only on uncached attempts, so if you refresh the next few attempts will return status code 200 instead until the cache expires.
This is probably the same on other sites, but know for sure it can be reproduced on the following commit:
The SpaControllerBase
class current contains a GetCultureIdFromUrl
method. This was created for a solution with a main site where the ID of the culture nodes are known, and can be hardcoded.
In a solution with more sites, the IDs of the culture nodes cannot be hardcoded, so we need a way to look them up dynamically. We can still use the GetCultureIdFromUrl
method to do so, but if we're using the content cache to find the current culture node, we might as well return an IPublishedContent
to begin with.
So we could add a method like:
protected IPublishedContent GetCultureFromUrl(SpaRequest request)
{
var culture = request.Url.Split('/')[1];
var cultures = request.Site.Children(SkyConstants.DocumentTypes.Culture).ToArray();
var cultureNode = cultures.FirstOrDefault(x => x.UrlName == culture) ?? cultures.FirstOrDefault();
return cultureNode;
}
Then both GetCultureFromUrl
and GetCultureIdFromUrl
would be available, and the latter could just be:
protected override int GetCultureIdFromUrl(SpaRequest request)
{
return GetCultureFromUrl(request)?.Id ?? 0;
}
The exception message should be wrapped in a <pre>
element, or at least render \n
as new lines. This will help with debugging should the exception message contain multiple lines.
Having most of these methods in directly the controller feels a bit dirty, and inheriting from the SpaControllerBase
prevents us from inheriting from a solution specific base class instead - which would make sense in some cases.
As a result of this, we should research moving some or probably most of these methods to the SpaRequest
class instead.
In a site we're automatically adding trailing slashes, which then also applies to to preview URLs.
Ideally we shouldn't do this for preview URLs, but the preview detection logic in the SPA might as well be updated to recognize preview URL with a trailing slash.
Some of the ignored properties - eg. Content
- should only be ignored when the declaring type is IPublishedContent
. This allows our custom models to have properties with these names - without our own properties being ignored.
Access-Control-Allow-Origin
header should be added on Executed event, not Executing. And on the response instead of the request 🙃
To have a more API-like behavior, @skybrud/frontenders would like the GetData endpoint to always return 200 OK, and then indicate the desired HTTP status code in the response body instead.
@skybrud/frontenders any preference for the JSON structure? Back in the day we had a meta
object with a status
property. Would this suffice?
Normally Umbraco would take care of either adding or removing trailing slashes, but as the SPA bypasses Umbraco's request pipeline, we need a way to handle this in the SPA.
This could be done in the form of a helper method, but leaving it up to each site implementation to call said helper method.
Se sidste 3 extensions skal flyttes. De andre er løsningsspecifikke
Vi mangler at flytte denne over i SPA pakken
`private void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs e)
{
//Bruges til at udføre custom-handlinger når et dokument er udgivet
Startup.ContentChangesGuid = Guid.NewGuid(); //clear localstorage on change
}`
Like we have Scripts.Add and Links.Add i miss a option to easily add meta-tags like <meta name="pageId" value="1234" />
As v3.0.0-beta013 introduced a breaking change around status code returned by the GetData endpoint, the idea was that the new behaviour could be disabled by setting the SpaRequestHelper.OverwriteStatusCodes
property to false
- but unfortunately the property was not implemented with a setter method, preventing developers from changing the value.
Cope from V7 branch to V8 branch:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.