Skip to content

Commit

Permalink
For #3 switch to gray-matter yaml parser for better user experience w…
Browse files Browse the repository at this point in the history
…ith long content fields. Support pure yaml as we have been doing, as well as traditional blogging front-matter format, with a content area that supports multiple named sections.
  • Loading branch information
victorkane committed Dec 3, 2018
1 parent 77f1672 commit 4ae0062
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
metaData:
itemSlug: awebfactory-dot-com-migration-case-study-and-book
itemName: Awebfactory.com Migration case-study and Book
Expand All @@ -11,12 +12,14 @@ metaData:
articleTitle: Awebfactory.com Migration case-study and Book
articleSubTitle: First step by step case study of a DurableDrupal Content Migration Rescue, from a Drupal 6 site to decoupled and scalable full-stack JavaScript
author: 'Victor Kane'
articleBody:
value: |
Learn and re-use all the methods and techniques for your own projects, from structured content modeling, to setting up the decoupled structured content server, the content management app, and the front-end client web app.
articleSummary:
value: |
Understand in full detail how this full stack JavaScript site was built, and how all content was migrated. So you can follow along and perform your own migrations and decoupled structured content projects.
tags:
- tagSlug: blog
tagName: blog
tagName: Blog
---
---articleSummary
---
Understand in detail how this full stack JavaScript site was built, and how all legacy content was migrated to it. Then you'll be all set to perform your own migrations and decoupled structured content projects.

---articleBody
---
Learn and re-use all the methods and techniques for your own projects, from structured content modeling, to setting up the decoupled structured content server, the content management app, and the front-end client web app.
14 changes: 7 additions & 7 deletions cms/content/articles/ddcmr-the-making-of.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
metaData:
itemSlug: ddcmr-the-making-of
itemName: DurableDrupal Content Migration Rescue website: the making of
itemName: DurableDrupal Content Migration Rescue website. The making of.
itemType: article
language: en-US
disabled: false
published: true
publishedDate: '2018-11-30'
createdDate: '2018-11-30'
modifiedDate: '2018-11-30'
articleTitle: DurableDrupal Content Migration Rescue website: the making of
publishedDate: 2018-11-30
createdDate: 2018-11-30
modifiedDate: 2018-11-30
articleTitle: DurableDrupal Content Migration Rescue website. The making of.
articleSubTitle: Step by step case study
author: 'Victor Kane'
articleBody:
value: |
Learn and re-use all the methods and techniques for your own projects, from structured content modeling, to setting up the decoupled structured content server, the content management app, and the front-end client web app.
Learn and re-use all the methods and techniques available here for your own projects, from structured content modeling, to setting up the decoupled structured content server, the content management app, and the front-end client web app.
articleSummary:
value: |
Understand in full detail how this full stack JavaScript site was built, as well as the way in which its decoupled architecture works. So you can build your own.
Understand exactly how this full stack JavaScript site was built, along with way its decoupled architecture works. So you can build your own.
tags:
- tagSlug: blog
tagName: blog
59 changes: 31 additions & 28 deletions cms/content/articles/what-is-content-migration-rescue.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
metaData:
itemSlug: what-is-content-migration-rescue
itemName: What Is Content Migration Rescue
Expand All @@ -11,45 +12,47 @@ metaData:
articleTitle: What is Content Migration Rescue and why do we need it?
articleSubTitle: null
author: 'Victor Kane'
articleBody:
value: |
### What is it?
tags:
- tagSlug: content-migration-rescue
tagName: Content Migration Rescue
- tagSlug: faq
tagName: FAQ
- tagSlug: what-why
tagName: What? Why?
vocabSlug: top-level-content
vocabName: Top Level Content
---
---articleSummary
---
### What is it?

A step-by-step approach offering freely shared resources needed for migrating your content from an obsolete, monolithic architecture, to a modern and truly scalable fullstack JavaScript set of decoupled applications and services.
A step-by-step approach offering freely shared resources needed for migrating your content from an obsolete, monolithic architecture, to a modern and truly scalable fullstack JavaScript set of decoupled applications and services.

Included here in this DurableDrupal Content Migration Rescue Website repo, and free to use with the same license used by Wikipedia (the Creative Commons Attribution-ShareAlike License) are a Node.js/Express.js/Mongoose/MongoDB API-first structured content server which exposes that content in a simple REST API (see the `scs` folder); a sample Vue.js/Nuxt.js/Vuetify.js based Client Web Application which consumes that REST API (see the `cwa` folder); a command-line and yaml/markdown based CMS which allows you to edit your content and send it to the structured content server (see the `cms` folder); together with a set of videos which explain in detail each step outlined in the [repo Project](https://github.com/DurableDrupal/ddcmr/projects/1), broken down into a sequence of atomic commits implementing the requirements outlined in the [repo issue queue](https://github.com/DurableDrupal/ddcmr/issues). The transcript of each video will be published in the [repo Wiki](https://github.com/DurableDrupal/ddcmr/wiki).
Included here in this DurableDrupal Content Migration Rescue Website repo is everything you need to work in the most efficient way possible with your own project.

And this is only the beginning. As soon as the website is up and running, we will publish our first case study, the migration of AwebFactory.com, the project founder's professional website now running on Drupal 6, to the same decoupled, API-first solution we are sharing here. The steps taken there will also be thoroughly explained and published in the form of a set of videos and a book, to be published on the DurableDrupal Content Migration Rescue Website we are building.
---articleBody
---
### What is it?

### Why do we need it?
A step-by-step approach offering freely shared resources needed for migrating your content from an obsolete, monolithic architecture, to a modern and truly scalable fullstack JavaScript set of decoupled applications and services.

Drupal 8 itself may very well be the ideal solution for many use cases. However, in the case of wishing to go API-first in the form of a decoupled approach, [things may get complicated very quickly](https://events.drupal.org/nashville2018/sessions/decoupled-drupal-hard-problems). Even though Drupal content may be served in the form of a REST API, the need for an asynchrounous or otherwise optimized server proxy has proven necessary for actually serving that content in real time. And so on.
Included here in this DurableDrupal Content Migration Rescue Website repo, and free to use with the same license used by Wikipedia (the Creative Commons Attribution-ShareAlike License) are a Node.js/Express.js/Mongoose/MongoDB API-first structured content server which exposes that content in a simple REST API (see the `scs` folder); a sample Vue.js/Nuxt.js/Vuetify.js based Client Web Application which consumes that REST API (see the `cwa` folder); a command-line and yaml/markdown based CMS which allows you to edit your content and send it to the structured content server (see the `cms` folder); together with a set of videos which explain in detail each step outlined in the [repo Project](https://github.com/DurableDrupal/ddcmr/projects/1), broken down into a sequence of atomic commits implementing the requirements outlined in the [repo issue queue](https://github.com/DurableDrupal/ddcmr/issues). The transcript of each video will be published in the [repo Wiki](https://github.com/DurableDrupal/ddcmr/wiki).

And when one turns to lists of other [Headless CMS](https://headlesscms.org/) hoping to find enticing alternatives, countless articles by dozens of developers witness the difficulties to be found in sifting through all these choices, both open source and commercial.
And this is only the beginning. As soon as the website is up and running, we will publish our first case study, the migration of AwebFactory.com, the project founder's professional website now running on Drupal 6, to the same decoupled, API-first solution we are sharing here. The steps taken there will also be thoroughly explained and published in the form of a set of videos and a book, to be published on the DurableDrupal Content Migration Rescue Website we are building.

We place this project at the service of a growing community of individuals and organizations willing to freely share and contribute to a set of simple, straightforward and transparently organized resources aimed at moving on with our content and web applications in the face of growing complexity and skyrocketing costs, both up-front in commercial form, or else hidden in the often disappointing experience of real adoption.
### Why do we need it?

At the hour of needing to move on to industry standard structured content managed and published on the basis of a decoupled and modern, scalable architecture, more and more we are faced with mystification, buzzwords and the unwillingness of companies born and raised on open source communities to share their solutions.
Drupal 8 itself may very well be the ideal solution for many use cases. However, in the case of wishing to go API-first in the form of a decoupled approach, [things may get complicated very quickly](https://events.drupal.org/nashville2018/sessions/decoupled-drupal-hard-problems). Even though Drupal content may be served in the form of a REST API, the need for an asynchrounous or otherwise optimized server proxy has proven necessary for actually serving that content in real time. And so on.

At the hour of adopting API-first structured content servers, more and more we are faced with the sole option of going behind a "serverless" paywall, which, to add insult to injury, powns our stuff.
And when one turns to lists of other [Headless CMS](https://headlesscms.org/) hoping to find enticing alternatives, countless articles by dozens of developers witness the difficulties to be found in sifting through all these choices, both open source and commercial.

At the hour of wanting to spin up client web applications, once again we are chronically placed at the mercy of open source projects made hopelessly chatoic to use due to a mind boggling rate of change as a result, once again, of having individual and community needs chained to the needs of large corporations and their compulsive and often irrational zigzags as they follow, cross-eyed, their own rapidly evolving crises and "opportunities".
We place this project at the service of a growing community of individuals and organizations willing to freely share and contribute to a set of simple, straightforward and transparently organized resources aimed at moving on with our content and web applications in the face of growing complexity and skyrocketing costs, both up-front in commercial form, or else hidden in the often disappointing experience of real adoption.

Perhaps by sharing our results in the community, we can turn a bewildering, demoralizing journey into a pleasing, exciting and above all, empowering experience.
articleSummary:
value: |
### What is it?
At the hour of needing to move on to industry standard structured content managed and published on the basis of a decoupled and modern, scalable architecture, more and more we are faced with mystification, buzzwords and the unwillingness of companies born and raised on open source communities to share their solutions.

A step-by-step approach offering freely shared resources needed for migrating your content from an obsolete, monolithic architecture, to a modern and truly scalable fullstack JavaScript set of decoupled applications and services.
At the hour of adopting API-first structured content servers, more and more we are faced with the sole option of going behind a "serverless" paywall, which, to add insult to injury, powns our stuff.

Included here in this DurableDrupal Content Migration Rescue Website repo...
tags:
- tagSlug: content-migration-rescue
tagName: Content Migration Rescue
- tagSlug: faq
tagName: FAQ
- tagSlug: what-why
tagName: What? Why?
vocabSlug: top-level-content
vocabName: Top Level Content
At the hour of wanting to spin up client web applications, once again we are chronically placed at the mercy of open source projects made hopelessly chatoic to use due to a mind boggling rate of change as a result, once again, of having individual and community needs chained to the needs of large corporations and their compulsive and often irrational zigzags as they follow, cross-eyed, their own rapidly evolving crises and "opportunities".

Perhaps by sharing our results in the community, we can turn a difficult and sometimes overwhelming journey into a pleasing, exciting and above all, empowering experience.

46 changes: 42 additions & 4 deletions cms/upsert/upsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// else 'cd upsert; node upsert authors nora-alicia-perusin'

const fs = require('fs')
const YAML = require('yamljs');
const rp = require('request-promise');
// const YAML = require('yamljs')
const yaml = require('js-yaml')
const matter=require('gray-matter')
const rp = require('request-promise')
require('dotenv').config()

// for more complete console log if necessary, such as the following:
Expand Down Expand Up @@ -152,11 +154,47 @@ async function processGenericContent(contentItem) {

const file = './content/' + contentType + '/' + param + '.md'

fs.readFile(file, 'utf8', function (err,content) {
fs.readFile(file, 'utf8', function (err,fileStr) {
if (err) {
return console.log(err)
}
contentItem = YAML.parse(content);

// legacy yamljs parsing
// contentItem = YAML.parse(content);

// gray-matter version
// first convert to front matter if yaml only
if (fileStr.substring(0,3) !== '---') {
// convert to standard front matter format with no "content",
fileStr = ("---\n" + fileStr + "\n---\n")
}

// parse, including sections
const matterJson = matter(fileStr, {
section: function(section, matterJson) {
if (typeof section.data === 'string' && section.data.trim() !== '') {
section.data = yaml.safeLoad(section.data);
}
section.content = section.content.trim() + '\n';
}
});

// console.log(JSON.stringify(matterJson, null, 2));

// iterate over gray-matter sections
// and insert them into data as expected by SCS
for (let i = 0; i < matterJson.sections.length; i++) {
// console.log('section ', matterJson.sections[i].key)
// console.log('content', matterJson.sections[i].content)
matterJson.data[matterJson.sections[i].key] = {
value: matterJson.sections[i].content
}
}

const contentItem = matterJson.data

// console.log(JSON.stringify(contentItem, null, 2));

let result = 0
if (contentType === 'articles') {
result = processArticles(contentItem)
Expand Down

0 comments on commit 4ae0062

Please sign in to comment.