Code Monkey home page Code Monkey logo

skybrud.umbraco.spa's People

Contributors

abjerner avatar tnielsenskybruddk avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

skybrud.umbraco.spa's Issues

Cached 404 page requests return statuscode 200

The issue

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.

Reproduction steps:

This is probably the same on other sites, but know for sure it can be reproduced on the following commit:

Add another method for finding the culture

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;
}

Research moving methods from SpaControllerBase to SpaRequest

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.

Improve preview detection logic

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.

GetData endpoint should always return 200 OK

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?

image

Add helper method to SpaRequestHelper for handling trailing slashes

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.

ContentChangeGuid on publication

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
    }`

Missing adding meta-tag option

Like we have Scripts.Add and Links.Add i miss a option to easily add meta-tags like <meta name="pageId" value="1234" />

SpaRequestHelper.OverwriteStatusCodes property does not have a setter method

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.