Code Monkey home page Code Monkey logo

musicfestival-vue-template's Introduction

MusicFestival Vue.js Templates

This sample site demonstrates one approach to render Episerver content in a client side framework that is using client side routing for navigation with a working On Page Edit (OPE) mode in the Episerver UI.

This particular solution uses Vue.js with Vuex to handle the state of the app in a single source of truth. Most of the techniques are framework agnostic and can be used with any other framework, such as React or Angular.

Content is fetched from Episerver using the Content Delivery API: https://world.episerver.com/documentation/developer-guides/CMS/Content/content-delivery-api/

Prerequisites

This project uses:

  • npm 6+
  • Visual Studio 2015+
  • SQL Server 2016 Express LocalDB (download here)

Setup and Run

  1. Run setup.cmd
  2. Open MusicFestival.Vue.Template.sln and hit Ctrl + F5
    • Or build with build.cmd, and set up the site on IIS or run site.cmd.
  3. Login on /episerver with either one of the following:
Name Password Mailbox Email
cmsadmin sparr0wHawk
emil sparr0wHawk https://www.mailinator.com/v3/index.jsp?zone=public&query=epic-emil [email protected]
ida sparr0wHawk https://www.mailinator.com/v3/index.jsp?zone=public&query=epic-ida [email protected]
alfred sparr0wHawk https://www.mailinator.com/v3/index.jsp?zone=public&query=epic-alfred [email protected]
lina sparr0wHawk https://www.mailinator.com/v3/index.jsp?zone=public&query=epic-lina [email protected]

Notable files

Vuex store modules

  • epiDataModel.js: the module that stores and updates the model object to be displayed on every component.
  • epiContext.js: makes inEditMode and isEditable flags available to the OPE helpers.

On-Page Editing helpers

  • epiEdit.js: a directive that can be added on components to make them optionally editable (e.g. <span v-epi-edit="Name">), through isEditable and epiDisableEditing.
  • EpiProperty.vue: a component that renders a button to edit a property (e.g. <epi-property property-name="Name">).
  • epiMessages.js: registers the contentSaved and epiReady message handlers that updates the vuex store.

Routing helpers

API

Overall structure

To avoid having multiple razor files the pages and blocks have their own controller and only one razor view each.

DefaultPageController.cs
    DefaultPage/Index.cshtml
        DefaultPage.vue
            router-view (Vue.js)
                router.js (Updates the store model with the url)
                    PageComponentSelector.vue (Use the model from the store)
                        ArtistContainerPage/ArtistDetailsPage/LandingPage.vue (Gets the model as a prop)

PreviewController.cs
    Preview/Index.cshtml (sets content-link attribute on <preview>)
        Preview.vue (Use and update the model in the store with the content link)
            BlockComponentSelector.vue (Gets the model as a prop and passes it on)
                BuyTicketBlock/ContentBlock/GenericBlock.vue (Gets the model as a prop)

Building client side resources

  • npm run webpack: Alias for npm run webpack-build-dev.
  • npm run webpack-build-dev: Builds a development package.
  • npm run webpack-watcher: Builds a development package, and re-builds automatically when relevant files are changed.
  • npm run webpack-build-prod: Builds a production package.

Debugging Vuex state

Using the Vue-devtools to see the state changes in the store in view mode works as expected. There are however some limitations to follow state changes when you are editing in Episerver edit mode because of the site is running inside an iframe. To be able to see the vuex state while editing you need to run the stand alone electron app as described on the github page: Vue standalone Electron app.

musicfestival-vue-template's People

Contributors

seriema avatar lingspb avatar dependabot[bot] avatar gregwiechec avatar nicklasisraelsson avatar skjelmo avatar valdisiljuconoks avatar

Watchers

James Cloos avatar

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.