Commit 846955c7 authored by Dan Allen's avatar Dan Allen
Browse files

merge !1079

resolves #1153 allow file to be explicitly marked as private; not private bypasses underscore check
parents ac8fbaee 01688764
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ This project utilizes semantic versioning.

=== Added

* *content-classifier*: Allow file to be explicitly marked as private; not private bypasses underscore check (#1153)
* *navigation-builder*: Propagate roles and additional link properties on xref to entry in navigation model (#1175)
* *page-composer*: Add `file` property to UI model of page that resolves to raw virtual file of page (#1165)
* *page-composer*: Add built-in `resolveResource` UI helper to resolve raw virtual file of resource by reference (#1167)
+3 −1
Original line number Diff line number Diff line
@@ -128,7 +128,9 @@ modules/
There must be one or more modules.
Files in the ROOT module are promoted a level above the named modules when published (effectively belonging to the component version itself).
AsciiDoc files are assumed to have the file extension `.adoc`.
Files and folders which begin with an underscore are cataloged, but not published.
Files that have a `private` property with the value `true` are cataloged, but not published.
Files that have a `private` property with the value `false` are cataloged and published if in a publishable family.
Otherwise, files and folders which begin with an underscore are cataloged, but not published.

The content catalog object (instance of `ContentCatalog`) produced by this component should provide a queryable index of virtual files.

+2 −1
Original line number Diff line number Diff line
@@ -180,8 +180,9 @@ class ContentCatalog {
    } else if ('out' in file) {
      delete file.out
    } else if (
      !file.private &&
      (family === 'page' || family === 'image' || family === 'attachment') &&
      ('/' + src.relative).indexOf('/_') < 0
      (file.private === false || ('/' + src.relative).indexOf('/_') < 0)
    ) {
      publishable = true
      if (componentVersion == null) componentVersion = this.getComponentVersion(component, version) || { version }
+52 −1
Original line number Diff line number Diff line
@@ -1355,6 +1355,23 @@ describe('ContentCatalog', () => {
      expect(contentCatalog.getPages()[0]).to.equal(result)
    })

    it('should not populate out and pub when file is marked as private', () => {
      const src = {
        component: 'the-component',
        version: '1.2.3',
        module: 'ROOT',
        family: 'page',
        relative: 'attributes.adoc',
        basename: 'attributes.adoc',
        extname: '.adoc',
        stem: '_attributes',
      }
      const contentCatalog = new ContentCatalog()
      const result = contentCatalog.addFile(new File({ src, private: true }))
      expect(result).to.not.have.property('out')
      expect(result).to.not.have.property('pub')
    })

    it('should not populate out and pub when filename begins with an underscore', () => {
      const src = {
        component: 'the-component',
@@ -1372,7 +1389,24 @@ describe('ContentCatalog', () => {
      expect(result).to.not.have.property('pub')
    })

    it('should not populate out and pub when file is in directory that begins with an underscore', () => {
    it('should populate out and pub when filename begins with an underscore and file is marked as not private', () => {
      const src = {
        component: 'the-component',
        version: '1.2.3',
        module: 'ROOT',
        family: 'page',
        relative: '_attributes.adoc',
        basename: '_attributes.adoc',
        extname: '.adoc',
        stem: '_attributes',
      }
      const contentCatalog = new ContentCatalog()
      const result = contentCatalog.addFile(new File({ src, private: false }))
      expect(result).to.have.property('out')
      expect(result).to.have.property('pub')
    })

    it('should not populate out and pub when file is in underscore directory', () => {
      const src = {
        component: 'the-component',
        version: '1.2.3',
@@ -1389,6 +1423,23 @@ describe('ContentCatalog', () => {
      expect(result).to.not.have.property('pub')
    })

    it('should populate out and pub when file is in underscore directory and file is marked as not private', () => {
      const src = {
        component: 'the-component',
        version: '1.2.3',
        module: 'ROOT',
        family: 'page',
        relative: '_attributes/common.adoc',
        basename: 'common.adoc',
        extname: '.adoc',
        stem: 'common',
      }
      const contentCatalog = new ContentCatalog()
      const result = contentCatalog.addFile(new File({ src, private: false }))
      expect(result).to.have.property('out')
      expect(result).to.have.property('pub')
    })

    it('should not populate out or pub property if out property of file is falsy', () => {
      const src = {
        component: 'the-component',