-
Notifications
You must be signed in to change notification settings - Fork 138
[Request for comments]: Site Versioning #1870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 23 commits
4eb63a8
e180361
c229160
e64f91c
778f3cb
95298d4
8eed90c
8453f7a
1ba8c91
f113c22
0769bc7
aca406b
7f559b1
792c156
4fc9090
798d63f
b85641a
9beec61
ad5f0ff
601d343
b52a341
039c0bd
f394060
c77b95e
5f8e427
2362390
3337749
46632f1
5ef1776
850aa18
d6cc776
a4505ce
f8ee5d7
1bdb924
3745f7a
d89e2a6
7d8125d
14fe6ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,78 @@ | ||||||||||||
| {% set title = "Site Versioning" %} | ||||||||||||
| {% set filename = "versioning" %} | ||||||||||||
| <span id="title" class="d-none">{{ title }}</span> | ||||||||||||
|
|
||||||||||||
| <frontmatter> | ||||||||||||
| title: "User Guide: {{ title }}" | ||||||||||||
| layout: userGuide.md | ||||||||||||
| </frontmatter> | ||||||||||||
|
|
||||||||||||
| <span id="link" class="d-none"> | ||||||||||||
| <md>[_User Guide → {{ title }}_]({{ filename }}.html)</md> | ||||||||||||
| </span> | ||||||||||||
|
|
||||||||||||
| # {{ title }} | ||||||||||||
|
|
||||||||||||
| <div class="lead" id="overview"> | ||||||||||||
|
|
||||||||||||
| Site versioning is key for documentation use, and websites may want to keep past versions for archival purposes. MarkBind can help you easily archive your site. | ||||||||||||
| </div> | ||||||||||||
|
|
||||||||||||
kaixin-hc marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||
| ## Archiving with a CLI command | ||||||||||||
|
|
||||||||||||
| Markbind allows you to easily save a version of the site you've built to be hosted at the same site with a modified URL with a [single CLI command](cliCommands.md#archive-command). All intralinks within the archived site will point to the respective archived pages. By default, the archived site is stored in a folder `version/<versionName>`, but you may specify your own archivePath. | ||||||||||||
kaixin-hc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
|
|
||||||||||||
| For example, if your site's base URL relative to your domain is `my_site`, and you archive a version named `v1` in the default archive folder, then by navigating to the URL `<domain>/my_site/version/v1/<someFile>` you can have accessed the archived version of `someFile`. | ||||||||||||
tlylt marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
|
|
||||||||||||
| A `versions.json` file will be created to track the archived sites you have made, and to exclude the archived sites from being re-archived the next time you make a new version. This file is **automatically updated** every time you archive a version. | ||||||||||||
|
|
||||||||||||
| <box type="warning"> | ||||||||||||
|
|
||||||||||||
| Modify versions.json with caution as it may result in unnecessary files being included or necessary files being excluded. | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion, as its a little difficult to see how this will pan out, we could leave this to be entirely internally managed by the cli commands for now:
Suggested change
if we don't want support these, could also move these chunks on
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mm, I agree with you, its just that I haven't implemented CLI commands to manage this yet so it might become necessary to edit it as a stopgap measure (changing the name of versions, for example, or deleting versions). I think using CLI commands to support renaming, deletion and maybe moving would be ideal, but might be outside the scope of this PR? Though I don't think it would be too difficult!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| * You may safely change the `versionName` of a version, **provided that it is unique** in versions.json. If you have specified versions to deploy in `site.json`, make sure you update the [versions property](siteJsonFile.md#versions) there as well. | ||||||||||||
|
|
||||||||||||
| * The baseUrl is used when setting the intra-site links; if you later change the baseUrl, previously saved versions with the past baseUrl will not be built/deployed even if specified because it would be a broken implementation. | ||||||||||||
|
Comment on lines
+58
to
+60
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps referring to the above comment thread from Ze Yu, we can make a new section of |
||||||||||||
|
|
||||||||||||
| </box> | ||||||||||||
|
|
||||||||||||
| ```json {heading="Example of a versions.json file"} | ||||||||||||
| { | ||||||||||||
| "versions": [ | ||||||||||||
| { | ||||||||||||
| "versionName": "v1", | ||||||||||||
| "buildVer": "3.1.1", | ||||||||||||
| "archivePath": "version/v1", | ||||||||||||
| "baseUrl": "/previousUrl" | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| "versionName": "v2", | ||||||||||||
| "buildVer": "3.1.1", | ||||||||||||
| "archivePath": "version/v2", | ||||||||||||
| "baseUrl": "/markbind" | ||||||||||||
| }, | ||||||||||||
| { | ||||||||||||
| "versionName": "v3", | ||||||||||||
| "buildVer": "3.1.1", | ||||||||||||
| "archivePath": "version/v3", | ||||||||||||
| "baseUrl": "/markbind" | ||||||||||||
| } | ||||||||||||
| ] | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| ``` | ||||||||||||
|
|
||||||||||||
| <include src="cliCommands.md#archiveWarning" /> | ||||||||||||
|
|
||||||||||||
| ## Working with sites with multiple versions | ||||||||||||
|
|
||||||||||||
| You may not always want to build all your saved versions. To specify the "default versions to build", add a [versions property](siteJsonFile.md#versions) in your `site.json` file. | ||||||||||||
kaixin-hc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
|
|
||||||||||||
| You may also specify which versions to build when using the build and serve cli commands([more information](cliCommands.md)). | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
|
|
||||||||||||
| ## Note on subsites | ||||||||||||
|
|
||||||||||||
| At present, when a site is archived and includes a subsite, it archives the subsite as it was at that point in time. Navigating to previous or future versions of the subsite from the parent site is not supported, though you can archive the subsite. | ||||||||||||
kaixin-hc marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||||||||
|
|
||||||||||||
| {% from "njk/common.njk" import previous_next %} | ||||||||||||
| {{ previous_next('deployingTheSite', 'markBindInTheProjectWorkflow') }} | ||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,6 +98,8 @@ program | |
| .option('-p, --port <port>', 'port for server to listen on (Default is 8080)') | ||
| .option('-s, --site-config <file>', 'specify the site config file (default: site.json)') | ||
| .option('-d, --dev', 'development mode, enabling live & hot reload for frontend source files.') | ||
| .option('-v, --versions [versionNames...]', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there are no values passed in, there's no point in the flag? In that case, perhaps we can make the values compulsory? What do you think?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this part was missed out @kaixin-hc (more than likely if you archive a site you'll want to deploy it too. Also @tlylt's point above) logically speaking, just this portion (SiteConfig.js) this.versions = siteConfigJson.versions !== undefined
? siteConfigJson.versions
: every version;(implementation wise you might want to do the check here instead) // change
if (versionsToGenerate === true) {
// copy no versions if the version flag is passed without arguments
} else if (versionsToGenerate === false) {
await this.copyVersions(desiredVersions
.filter(vers => this.siteConfig.versions.includes(vers.versionName)));
} else {
await this.copyVersions(desiredVersions
.filter(vers => versionsToGenerate.includes(vers.versionName)));
}
// into
if (versionsToGenerate === true) {
// copy no versions if the version flag is passed without arguments
} else if (versionsToGenerate is an array) {
// cli override takes precedence
await this.copyVersions(desiredVersions
.filter(vers => versionsToGenerate.includes(vers.versionName)))
} else if (/* versionsToGenerate === false (implied) && */ this.siteConfig.versions is an array) {
// does site.json have the property? use it next if so
await this.copyVersions(desiredVersions
.filter(vers => this.siteConfig.versions.includes(vers.versionName)));
} else {
// **the default** - deploy all previously archived versions versions
await this.copyVersions(desiredVersions
.filter(vers => versionsToGenerate.includes(vers.versionName)));
}
// and change (SiteConfig.js)
this.versions = siteConfigJson.versions !== undefined
? siteConfigJson.versions : [];
// into just
this.versions = siteConfigJson.versions;The flag behaviour looks good though! |
||
| 'specify versions to be deployed. if flag is used without specification, deploy all versions') | ||
| .action((userSpecifiedRoot, options) => { | ||
| if (options.dev) { | ||
| logger.useDebugConsole(); | ||
|
|
@@ -262,7 +264,7 @@ program | |
| serverConfig.open = serverConfig.open && `${config.baseUrl}/`; | ||
| } | ||
|
|
||
| return site.generate(); | ||
| return site.generate(undefined, options.versions); | ||
| }) | ||
| .then(() => { | ||
| const watcher = chokidar.watch(rootFolder, { | ||
|
|
@@ -298,6 +300,8 @@ program | |
| .option('--baseUrl [baseUrl]', | ||
| 'optional flag which overrides baseUrl in site.json, leave argument empty for empty baseUrl') | ||
| .option('-s, --site-config <file>', 'specify the site config file (default: site.json)') | ||
| .option('-v, --versions [versionNames...]', | ||
| 'specify versions to be deployed. if flag is used without specification, deploy all versions') | ||
| .description('build a website') | ||
| .action((userSpecifiedRoot, output, options) => { | ||
| // if --baseUrl contains no arguments (options.baseUrl === true) then set baseUrl to empty string | ||
|
|
@@ -311,13 +315,33 @@ program | |
| const defaultOutputRoot = path.join(rootFolder, '_site'); | ||
| const outputFolder = output ? path.resolve(process.cwd(), output) : defaultOutputRoot; | ||
| new Site(rootFolder, outputFolder, undefined, undefined, options.siteConfig) | ||
| .generate(baseUrl) | ||
| .generate(baseUrl, options.versions) | ||
| .then(() => { | ||
| logger.info('Build success!'); | ||
| }) | ||
| .catch(handleError); | ||
| }); | ||
|
|
||
| program | ||
| .command('archive [versionName] [archivePath]') | ||
|
||
| .alias('ar') | ||
| .option('-s, --site-config <file>', 'specify the site config file (default: site.json)') | ||
| .description('archive a version of the site, which is not affected by later changes to the site') | ||
| .action((versionName, userSpecifiedArchivePath, options) => { | ||
| if (!versionName) { | ||
| logger.error('Please specify a name for the archived version.'); | ||
|
||
| } | ||
| const archivePath = userSpecifiedArchivePath || `version/${versionName}`; | ||
| const rootFolder = path.resolve(process.cwd()); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wonder if we should add in I think minimally we could add in a small note in the cli commands page that the site archived is the |
||
| const outputFolder = path.join(rootFolder, archivePath); | ||
| new Site(rootFolder, outputFolder, undefined, undefined, options.siteConfig) | ||
| .archive(versionName, archivePath) | ||
| .then(() => { | ||
| logger.info(`Successfully archived ${versionName} at ${archivePath}`); | ||
| }) | ||
| .catch(handleError); | ||
| }); | ||
|
|
||
| program | ||
| .command('deploy') | ||
| .alias('d') | ||
|
|
@@ -327,7 +351,8 @@ program | |
| .action((options) => { | ||
| const rootFolder = path.resolve(process.cwd()); | ||
| const outputRoot = path.join(rootFolder, '_site'); | ||
| new Site(rootFolder, outputRoot, undefined, undefined, options.siteConfig).deploy(options.ci) | ||
| new Site(rootFolder, outputRoot, undefined, undefined, options.siteConfig) | ||
| .deploy(options.ci) | ||
| .then(depUrl => (depUrl !== null ? logger.info( | ||
| `The website has been deployed at: ${depUrl}`) | ||
| : logger.info('Deployed!'))) | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,7 @@ module.exports = { | |||||
| PAGE_TEMPLATE_NAME: 'page.njk', | ||||||
| SITE_CONFIG_NAME: 'site.json', | ||||||
| SITE_DATA_NAME: 'siteData.json', | ||||||
| VERSIONS_DATA_NAME: 'versions.json', | ||||||
|
||||||
| VERSIONS_DATA_NAME: 'versions.json', | |
| VERSIONS_DATA_NAME: '_markbind/versions.json', |
should we? in view of all the other stuff in there

Uh oh!
There was an error while loading. Please reload this page.