Hello,
I wanted to create a personalized sample like the 2 you have (Blog Sample, Profile Sample).
I’ve searched for documentation on how to do it but found nothing.
Hi Melo,
what programming language do you use? Documentation is lacking but there are a few samples for both samples:
Hello, I am using c#.
I’ve looked into that repository but I don’t want client examples.
I wanted to modify the project so that I could have my own sample when creating an app (with pre-defined schemas).
But I found no documentation about developing new samples.
Hi, the full sample system is obsolete and I hope I can remove it soon.
But there is a small sample for the current system: You have to implement such a class and register it:
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using Squidex.Domain.Apps.Core.Schemas;
using Squidex.Domain.Apps.Entities.Apps.Templates;
using Squidex.Domain.Apps.Entities.Apps.Templates.Builders;
namespace Squidex.Extensions.Samples.Middleware
{
public class TemplateInstance : ITemplate
{
public string Name { get; } = "custom2";
public Task RunAsync(PublishTemplate publish)
{
var schema =
SchemaBuilder.Create("Blogs")
.AddString("Title", f => f
.Properties(p => p with
{
Registration:
using Squidex.Infrastructure.Plugins;
namespace Squidex.Extensions.Samples.Middleware
{
public sealed class TemplatePlugin : IPlugin
{
public void ConfigureServices(IServiceCollection services, IConfiguration config)
{
services.AddSingleton<ICustomCommandMiddleware, TemplateMiddleware>();
services.AddSingleton<ITemplate, TemplateInstance>();
}
}
}
When you create an app you have to define the template name. The list of templates in the frontend is hardcoded at the moment, so you would also have to add a new menu item for that.
Thanks a lot! I will try it.
What do you mean by removing it?
I have answered it on this task:
Problem
The current system has a few limitations:
It only supports a subset of what is possible through an easy interface. Theoretically you can create everything using code, but it is not that easy.
There is not progress tracking or so, which is a problem for large samples. In case the system or node is restarted while a large sample is integrated you cannot restart or continue.
You need to modify the code to make custom samples. It would be normal for a CMS, but for a headless CMS nobody is …
I need to try the current template system. But when I run the front-end it does not work.
I tried with different node versions and I was following the docs.
Hi, how do you run it? Usually it should be https://localhost:5001 and not port 3000
Btw: This is how it works now.
There is a client class which scans repositories for samples:
// ==========================================================================
// Squidex Headless CMS
// ==========================================================================
// Copyright (c) Squidex UG (haftungsbeschraenkt)
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
using System.Net;
using System.Text.RegularExpressions;
using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Entities.Apps.Templates
{
public sealed class TemplatesClient
{
private const string DetailUrl = "https://raw.githubusercontent.com/Squidex/templates/main";
private const string OverviewUrl = "https://raw.githubusercontent.com/Squidex/templates/main/README.md";
private static readonly Regex Regex = new Regex("\\* \\[(?<Title>.*)\\]\\((?<Name>.*)\\/README\\.md\\): (?<Description>.*)", RegexOptions.Compiled | RegexOptions.ExplicitCapture);
private readonly IHttpClientFactory httpClientFactory;
This file has been truncated. show original
All templates that are named with “Starter” are considered starter and shown in the overview page.
I have created a core package of the CLI which contains all relevant classes and the code in the API just triggers the CLI:
It basically works by cloning the git repository to temp folder and then running the CLI over the API with the just created app.
Furthermore there is a new gallery section in the sections:
So what you can do to create new samples:
Alternative 1: Create a custom repository if you host Squidex yourself.
Alternative 2: Create a fork of the official repository and provide your template as pull request.
I was following this Developing - Squidex
But it mentions you should go to https://localhost:5001 at the end.
I was able to run it.
I have created a repository with a template and tried to create an app using it.
However I was not able to create the app with the template from the web.
What exactly do you mean with that?
Shouldn’t it be possible to create the app with the template from here?
Yes, what happens if you click it?
It creates the app, but empty.
I tested with the default repository and it happens too.
Sorry, something has been removed with a merge. I will fix it asap.
1 Like
Thanks a lot, I will try it.