Coder Social home page Coder Social logo

mulliman / xstatic-for-umbraco Goto Github PK

View Code? Open in Web Editor NEW
42.0 3.0 11.0 9.05 MB

This is a static site generator built for Umbraco so that you can host simple Umbraco sites on fast and cheap hosting providers such as netlify.

C# 20.42% JavaScript 62.43% HTML 10.61% CSS 6.36% ASP.NET 0.17%
umbraco netlify static-site-generator

xstatic-for-umbraco's Introduction

xStatic-for-Umbraco

This is a static site generator built for Umbraco so that you can host simple Umbraco sites on fast and cheap hosting providers such as netlify.

For more information on why it could be of use to you, please visit https://www.sammullins.co.uk/software/xstatic-for-umbraco/

xStatic can be extended to meet specific needs and documentation for this can be found at https://www.sammullins.co.uk/software/xstatic-for-umbraco/extending-xstatic/

Getting started

  1. Ensure that Umbraco is installed and working before running the site with xStatic installed.

  2. Add the following to the ConfigureServices method in your Startup.cs file

services.AddXStatic().Automatic().Build();

You will need to add using XStatic.Core.App; to the top of the file.

This will automatically register all the built in services as required for an out of the box solution.

  1. Ensure that the \App_Plugins\xStatic folder and files are included in your csproj. These need to be present in your website for the xStatic section to appear.

  2. In the users section, add 'xStatic Generated Sites' to the roles you want to have access.

  3. Create your site configs and build / deploy your static sites.

xstatic-for-umbraco's People

Contributors

adam-werner avatar hifi-phil avatar mulliman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

xstatic-for-umbraco's Issues

Upgrading xStatic deletes user config

Hi Sam

Just upgraded to 1.1 and the process wiped out my local config. Might be better to move the config file to the config directory in Umbraco?

Phil

Question: Is it possible to handel 301/302 redirects

I'm thinking of using xStatic for some sites that have been live for some period of time. If we were to do so we would require support for some legacy URLs for SEO and other activities.

Is this possible or would much of that be lost when generating the site statically?

Wildcard support for Asset Paths

It would be useful to being able to input asset paths with a wildcard e.g. /lib/* when including assets so that they get added recursively ๐Ÿ˜๐Ÿ˜

Image Cropper with alias not working

The Media Crops only works when you have the .GetCropUrl(940, 720) extension method with the dimensions hardcoded. I have a website with multiple crops defined in the media picker. This is not recognized by the plugin and will keep the 'default' crop URL with parameters, which of course does not work after it is generated.
Also this means the focus point is not included.

Is it possible to also make the media crops with alias possible? I can image that there must be some way by looking at the image query parameters in post processing?

Error getting value from 'Warnings' on 'XStatic.Core.Generator.Processes.RebuildProcessResult'.

Hi,

I have applied the Netlify404Action as seen below. When I add this to my Netlify site and try to build I get an exception.

image

These are build settings:
image

I have an Umbraco Node named 404 and I verified it outputs as 404/index.html

[20:50:55 ERR] Unhandled controller exception occurred for request '/umbraco/backoffice/xstatic/Generate/RebuildStaticSite/?staticSiteId=2'
Newtonsoft.Json.JsonSerializationException: Error getting value from 'Warnings' on 'XStatic.Core.Generator.Processes.RebuildProcessResult'.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'source')
   at System.Linq.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
   at System.Linq.Enumerable.Where[TSource](IEnumerable`1 source, Func`2 predicate)
   at XStatic.Core.Generator.Processes.RebuildProcessResult.get_Warnings()
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   --- End of inner exception stack trace ---
   at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|30_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilder.<>c.<<BuildPipeline>b__8_0>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.BackOffice.Filters.UnhandledExceptionLoggerMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
   at Umbraco.Cms.Web.Common.Middleware.BasicAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.BackOffice.Middleware.BackOfficeExternalLoginProviderErrorMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
   at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at SixLabors.ImageSharp.Web.Middleware.ImageSharpMiddleware.Invoke(HttpContext httpContext, Boolean retry)
   at StackExchange.Profiling.MiniProfilerMiddleware.Invoke(HttpContext context) in C:\projects\dotnet\src\MiniProfiler.AspNetCore\MiniProfilerMiddleware.cs:line 119
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.PreviewAuthenticationMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Umbraco.Cms.Web.Common.Middleware.UmbracoRequestLoggingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
   at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Request: Add textbox to the actions field options

Hi,

I have a feature request for the action parameters. This is a single line textfield right now but it would be nice if we could have a textbox which supports multiple lines. I want to write a post action that adds a _headers file to the output for Netlify but right now I have to do this hardcoded because the input from the CMS does not support multiple lines.

I am using it so the rss index file returns with the right content type for browsers to understand.

image

Would like to contribute above action to the Netlify package because I think it will be useful. But of course above version is not enough for the package because it is static.

Linux environment not able to create directories in App_Data

In testing the Build of a saved site, the writing of the site to the Umbraco environment fails. The resulting error output with the CMS in debug = true follows:

Received an error from the server
An error occurred
Could not find a part of the path '/home/site/wwwroot/App_Data/xStatic/output/1/index.html'.

Exception Details
System.IO.DirectoryNotFoundException, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e: Could not find a part of the path '/home/site/wwwroot/App_Data/xStatic/output/1/index.html'.

I've attached the stacktrace.txt from this error for additional review.

Interestingly enough, while troubleshooting to this point, if the directory structure is pre-seeded, an index.html file is saved but further directories cannot be constructed in that directory.

To confirm, the Build function works as expected in a Windows environment, it just appears that directories are not able to be constructed.

I would like to take this issue and work on a solution for your review.

Thank you.

Umbraco V9

Hi, do you have any intentions in supporting Umbraco v9 in dotnet core?

Sitemap and 404

Hi Sam

Just to let you know we released our first xStatic site today.

https://www.superfried.com/

Working really well so far and really enjoying working with Netlify.

Once takeaway from our deployment, how do we deal with sitemap and 404 files.

The sitemap should be at sitemap.xml and in an XML format (it currently creates a HTML file)
The 404 for netlify needs to be at /404.html

I overrode your generator for both these and it works well but maybe worth adding something to make these files more obvious / easy.

Hope that makes sense.

Phil

Link href values to .CSS files not generating correctly

Hi there!

While I'm able to use xStatic to create a static version of my site with all the assets, the <head> elements of each page are missing the href values for the .CSS files. All the .CSS files have been copied across as expected.

The links to the .CSS files are created in Umbraco using SmidgeHelper.

Original

@{
    SmidgeHelper.RequiresCss("~/clean-assets/css/styles.css");
}

<head>
   @await SmidgeHelper.CssHereAsync(debug: false)
</head>

xStatic

    <!-- Core theme CSS (includes Bootstrap)-->
    <link href="/sc/0c03902b.css.v1" rel="stylesheet">

This may be a case of me not having implemented (any) transformers, or any other functionality of xStatic.

Unsure if this is an issue and more just me missing something, but let me know how I can set the links correctly.

Thank you so much for making this package, it's HUGELY valuable - hope to get to know it better to be able to support it in future!

Rich

System info:

Category Data
Server OS Microsoft Windows 10.0.22621
Server Framework .NET 6.0.24
Default Language en-US
Umbraco Version 10.7.0
Current Culture en-US
Current UI Culture en-US
Current Webserver IIS
Models Builder Mode SourceCodeManual
Debug Mode True
Database Provider Microsoft.Data.SqlClient
Current Server Role Single
Browser Edge-chromium 118.0.2088.61
Browser OS Win32

Adding pagination to a page

Hi,

I have a question, maybe feature request but not sure how to tackle it with your plugin. My personal website uses xStatic and it's great. Thanks!

I have a blogs page and it's getting a bit long, so I want xStatic to render pages for as long as there are results.

Right now a page works with /blogs?page=1 and it's ok to make this /blogs/1 for example.

How would you tackle this?

Language variants

I've noticed that when I build my HTML site, none of the language variants are generated and only the default language is available. Could export of these translated pages be added?

Auto deploy doesn't appear to work

When publishing changes in Umbraco for a site with XStatic configured and auto deploy enabled, the build & deployment doesn't automatically fire.

Could not load type 'SqlGuidCaster', Umbraco 13.4.0

When trying to install on an Umbraco 13.4.0 I get the following error when accessing the dashboard:

Unable to load one or more of the requested types. Could not load type 'SqlGuidCaster' from assembly 'Microsoft.Data.SqlClient, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5' because it contains an object field at offset 0 that is incorrectly aligned or overlapped by a non-object field.

I've attached the full stacktrace here.
And I've also added the Program.cs as a .txt file.

xstatic_details.txt
Program.txt

Add client-side validation to the definition forms

In the Site Definition, Action Definition and Export Type Definition forms, submissions without field entries can result in an error.

Site Definition Form

sc-xstatic-site-definition
sc-xstatic-site-definition-error

Action Definition Form

sc-xstatic-action-definition
sc-xstatic-action-definition-error

Export Type Definition

sc-xstatic-exporttype-definition
sc-xstatic-exporttype-definition-error

Possible solution approach

With some angularjs controller updates, form validation can be incorporated there. Alternatively, the corresponding API endpoints being called by the angularjs controllers can return validation messaging errors.

xStatic export as html problem

Hello!

I'm using xStatic v1.1.0 on umbraco v8.17.1.
All was working well until the 'export as html' stopped working.
All assets are being deployed correctly but there is no html.

Any idea why?
Thanks!

User permissions on dashboard

When adding the user group xStatic to the Editor role the section link is available but the dashboard doesn't display so they can't upload sites. Strangely they can edit generated site settings.

A controller with this name is not registered

When deployed to an Azure App Service, the dashboards don't render and Angular JS errors are thrown:

Error: $controller:ctrlreg
A controller with this name is not registered

This appears for each of the XStatic dashboard controllers as I navigate through them.

image

Netlify doesn't appear after installation

As you can see, I've installed the xStatic.Netlify package on my umbraco installation, but for some reason it looks like that it never gets picked up ๐Ÿคทโ€โ™‚๏ธ

Shows that the package is installed in the project
image

The Deployment Target dropdown is empty
image

The umbraco solution doesn't reflect that the Netlify extension should be installed
image

Fails when using with Azure block file provider

Thanks Sam, great package. Having some fun with images though!?!?

Tried to use it with the Azure blob file provider (https://our.umbraco.com/packages/collaboration/umbracofilesystemprovidersazure/)

and it fails then deploying because it's trying to download the image from a local path which doesn't exist.

I can help with a PR if you point me in the right direction.

Also RE NuGet, I've talked to Matt Wise and we'll be happy to help you set up GitHub actions to deploy directly to Nuget if you would like?

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.