All Projects → cofoundry-cms → Cofoundry.Samples.SPASite

cofoundry-cms / Cofoundry.Samples.SPASite

Licence: MIT license
A simple single page application using Cofoundry as a headless CMS

Programming Languages

C#
18002 projects
TSQL
950 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects
SCSS
7915 projects

Projects that are alternatives of or similar to Cofoundry.Samples.SPASite

teched2021-developer-keynote
SAP TechEd 2021 Developer Keynote: Improving Developers' Lives.
Stars: ✭ 23 (-23.33%)
Mutual labels:  sample
BlazorDemo
Demo application for my writings about Blazor
Stars: ✭ 79 (+163.33%)
Mutual labels:  spa
flutter-animations
medium.com/flutter-jp/implicit-animation-b9d4b7358c28
Stars: ✭ 37 (+23.33%)
Mutual labels:  sample
angolans-on-github
Software Developers based in Angola 🇦🇴
Stars: ✭ 18 (-40%)
Mutual labels:  spa
3dsMax-Python-HowTos
3ds Max python samples
Stars: ✭ 86 (+186.67%)
Mutual labels:  sample
cloud-platform-iot-starterkit
This repository provides information and code for working with SAP Cloud Platform Internet of Things. It enables users to get an end-to-end IoT solution with either real hardware or simulators up and running fast and start their own extensions and usage based on this.
Stars: ✭ 276 (+820%)
Mutual labels:  sample
waltz
A general purpose web application that provides the interface between SCADA(s) system and the scientific users who define and calibrate their experiments
Stars: ✭ 17 (-43.33%)
Mutual labels:  spa
byd-api-samples
A set of Postman collections that enables users to consume SAP Business ByDesign web services.
Stars: ✭ 49 (+63.33%)
Mutual labels:  sample
nextjs-react-router
A demonstration of how to use React Router inside Next.js
Stars: ✭ 64 (+113.33%)
Mutual labels:  spa
cloud-sample-spaceflight-java
Build Java applications with the application programming model on SAP Cloud Platform.
Stars: ✭ 49 (+63.33%)
Mutual labels:  sample
prax
Experimental rendering library geared towards hybrid SSR+SPA apps. Focus on radical simplicity and performance. Tiny and dependency-free.
Stars: ✭ 18 (-40%)
Mutual labels:  spa
llapi-example
LLAPI Networking sample (Top Down Shooter)
Stars: ✭ 26 (-13.33%)
Mutual labels:  sample
ConductOfCode
Code examples for the blog
Stars: ✭ 15 (-50%)
Mutual labels:  sample
azure-sdk-for-python-keyvault-secrets-get-set-managedid
How to set and get secrets from Azure Key Vault with Azure Managed Identities and Python
Stars: ✭ 13 (-56.67%)
Mutual labels:  sample
componentjs
ComponentJS -- Powerful run-time Component System for structuring HTML5-based Rich Clients
Stars: ✭ 83 (+176.67%)
Mutual labels:  spa
GStreamer-Python
Fetch RTSP Stream using GStreamer in Python and get image in Numpy
Stars: ✭ 81 (+170%)
Mutual labels:  sample
cloud-abap-rap
This repository contains several examples how to develop with the ABAP RESTful Application Programming Model (RAP) in SAP BTP, ABAP environment.
Stars: ✭ 98 (+226.67%)
Mutual labels:  sample
datamosh
✨💾 Edit images via buffers. 💯✨
Stars: ✭ 23 (-23.33%)
Mutual labels:  cat
SvelteScaling
Does Svelte scale?
Stars: ✭ 21 (-30%)
Mutual labels:  spa
elm-news
All elm news in one place
Stars: ✭ 60 (+100%)
Mutual labels:  spa

Cofoundry.Samples.SPASite

This sample shows how to use Cofoundry to create a SPA (Single Page Application) with WebApi endpoints as well as demonstrating some advanced Cofoundry features. The application is also separated into two projects demonstrating an example of how you might structure your domain layer to keep this separate from your web layer.

This sample uses Vue.js as the SPA framework, but this is easily swapped out for another SPA framework as all interactions are made over a REST API.

Notable features include:

  • Startup registration
  • Web Api, use of IApiResponseHelper and managing command validation errors in a SPA
  • Structuring commands and queries using CQS
  • Multiple related custom entities - Cats, Breeds and Features
  • A member area with a sign-up and login process
  • Using an Entity Framework DbContext to represent custom database tables
  • Executing stored procedures using IEntityFrameworkSqlExecutor
  • Integrating custom entity data with Entity Framework data access
  • Using the auto-updater to run SQL scripts
  • Email notifications & email templating
  • Registering services with the DI container

To get started:

  1. Create a database named 'Cofoundry.Samples.SPASite' and check the Cofoundry connection string in the app.settings file is correct for your SQL Server instance
  2. Run the website and navigate to "/admin", which will display the setup screen
  3. Enter an application name and setup your user account. Submit the form to complete the site setup.
  4. Either sign in and enter your own data or follow the steps below to import some test data

Importing test data:

To get you started we've put together some optional test data:

  1. Run InitData\Init.sql script against your db to populate some initial cats and features
  2. Copy the images from "\InitData\Images" to "\src\Cofoundry.Samples.SPASite\App_Data\Files\Images"
  3. Either restart the site, or go to the settings module in the admin panel and clear the cache.

App Overview

SPA Cats is a simple site that lets you browse and rate cats. Cat data can be entered into the Cofoundry CMS admin panel, which is then displayed on the homepage. Users can browse the data, register as a member and vote for their favorite cat.

SPA Cats Homepage

Managing Content

To manage content you'll need to log in to the admin panel by navigating to /admin.

Adding New Cats

Domain solution structure

Once logged in, navigate to Content > Cats. This section is generated automatically based on the CatCustomEntityDefinition class in the Domain project. Click on the Create button to add a new Cat.

Domain solution structure

The data entry form is generated based on the CatDataModel, a simple class with annotated properties. The Cat custom entity type has versioning enabled, so we can either save the new cat as a draft version or make it live by publishing it.

The two other custom entities Breeds and Features can be managed in the same way.

Code

In this example we demonstrate separating your application into two projects to represent two distinct layers. For a simpler example which keeps all files in one project see Cofoundry.Samples.SimpleSite.

Cofoundry.Samples.SpaSite.Domain

Contains domain logic and data access.

Domain solution structure

  • Data: We use some custom SQL tables to store cat popularity data. An Entity Framework DbContext is used to access the custom tables.
  • Domain: The domain contains all the models, queries and commands that we use to retrieve and store data. It also contains the Custom Entity Definitions that define the Breed, Cat and Features custom entities, and the User Area Definition that defines the Members login area. Structuring our code in this way gives us a clean separation between our domain logic layer and our application layer.
  • Install: Here we take advantage of the Auto Update feature in Cofoundry to run SQL scripts that create our custom tables and stored procedures.
  • MailTemplates: We store our mail templates in the domain layer so they can be used from inside our commands. Because we are including the template cshtml files as embedded resources here, we need to include an AssemblyResourceRegistration which is located in the bootstrap folder.

Cofoundry.Samples.SpaSite.Web

Because all our logic is in the domain layer, our website project is fairly simple.

Web solution structure

  • Api: Contains our web api controllers. These are quite lightweight and mostly just wrap our domain queries and commands.
  • App_Data: This folder contains any asset files uploaded to the CMS.
  • ClientApp: SPA Cats is written in Vue.js, but you could use any framework you like. The ClientApp folder contains all the Vue.js front-end code and build files.
  • Startup.cs: Cofoundry startup and registration is handled via the standard .NET Core startup.cs file in the application root. There's some additional code here to bootstrap the Vue project using the VueCliMiddleware NuGet package.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].