Skip to content

Commit

Permalink
Merge branch 'master' into Added_a_examples_08-11-23
Browse files Browse the repository at this point in the history
  • Loading branch information
cfmitrah authored Aug 12, 2024
2 parents c4432cf + 347037e commit 3d63b52
Show file tree
Hide file tree
Showing 439 changed files with 17,615 additions and 307 deletions.
66 changes: 66 additions & 0 deletions .github/scripts/generate-index-recipes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const fs = require('fs-extra');
const path = require('path');
const crypto = require('crypto');

async function generateIndex() {
const recipesDir = path.join(__dirname, '../../docs/recipes');
const outputPath = path.join(recipesDir, 'index.json');
const readmePath = path.join(recipesDir, 'README.md');
const files = await fs.readdir(recipesDir);
const index = [];
let readmeContent = '# Recipes\n\n';

console.log('Generating index and README...');
console.log(`Reading files from ${recipesDir}`);

for (const file of files) {
if (file.endsWith('.md') && file !== 'README.md') {
console.log(`Processing file: ${file}`);
const filePath = path.join(recipesDir, file);
const content = await fs.readFile(filePath, 'utf-8');
const titleMatch = content.match(/^#\s+(.+)$/m);
const title = titleMatch ? titleMatch[1] : 'Untitled';
const hash = crypto.createHash('md5').update(content).digest('hex');

// Extract metadata from the comment block
const metadataMatch = content.match(/<!--\s*({[^]*?})\s*-->/);
let description = 'No description available.';
let keywords = [];
if (metadataMatch) {
const metadata = JSON.parse(metadataMatch[1]);
if (metadata.description) {
description = metadata.description;
}
if (metadata.keywords) {
keywords = metadata.keywords;
}
}

index.push({
file: file,
title: title,
path: `/docs/recipes/${file}`,
hash: hash,
keywords: keywords
});

readmeContent += `## [${title}](/docs/recipes/${file})\n\n${description}\n\n`;
}
}

console.log(`Writing index to ${outputPath}`);
await fs.writeJson(outputPath, index, { spaces: 2 });

console.log(`Writing README to ${readmePath}`);
await fs.writeFile(readmePath, readmeContent.trim(), 'utf-8');

const readmeExists = await fs.pathExists(readmePath);
console.log(`README exists: ${readmeExists}`);

console.log('Index and README generation complete.');
}

generateIndex().catch(err => {
console.error('Error generating index and README:', err);
process.exit(1);
});
43 changes: 43 additions & 0 deletions .github/workflows/index-recipes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Generate Recipes Index

on:
push:
branches:
- "**"
paths:
- "docs/recipes/**"
workflow_dispatch:

jobs:
generate-index:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: |
npm install fs-extra
- name: Generate index
run: |
node .github/scripts/generate-index-recipes.js
- name: Commit and push changes
run: |
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})
if [ -n "$(git status --porcelain)" ]; then
git config --local user.email "[email protected]"
git config --local user.name "Lucee Docs GitHub Action"
git add docs/recipes/index.json docs/recipes/README.md
git commit -m "Update recipes index and README"
git push origin $BRANCH_NAME
else
echo "No changes found to commit"
fi
10 changes: 5 additions & 5 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
name: 🧹 Markdown Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: 🥝 Use Node.js
uses: actions/setup-node@v3.5.1
uses: actions/setup-node@v4
with:
node-version: '12.x'
- run: npm install -g [email protected]
Expand All @@ -19,7 +19,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 🍉 Check Out
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 🥥 Install
run: |
wget -O - -q https://git.io/misspell | sh -s -- -b .
Expand All @@ -30,8 +30,8 @@ jobs:
name: 🧹 YAML Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4.3.0
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax
architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: lucee-script-runner-m2-cache
- name: Cache Lucee files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: _actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads-${{ env.luceeVersion }}
Expand All @@ -39,11 +39,11 @@ jobs:
with:
webroot: ${{ github.workspace }}
execute: /build-all.cfm
luceeVersion: 6.0.0.572-SNAPSHOT
luceeVersion: 6.1.0.238-SNAPSHOT
# redis, chart, lucene, form. ajax, chart
extensions: 60772C12-F179-D555-8E2CD2B4F7428718;version=3.0.0.54-SNAPSHOT,D46B46A9-A0E3-44E1-D972A04AC3A8DC10,EFDEB172-F52E-4D84-9CD1A1F561B3DFC8,FAD67145-E3AE-30F8-1C11A6CCF544F0B7,6E2CB28F-98FB-4B51-B6BE6C64ADF35473,DF28D0A4-6748-44B9-A2FDC12E4E2E4D38
- name: Upload Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: lucee-docs
path: builds/artifacts/lucee-docs.zip
Expand All @@ -61,7 +61,7 @@ jobs:
run: curl https://google.com/ping?sitemap=https://docs.lucee.org/sitemap.xml
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master'}}
# - name: Notify slack
# uses: 8398a7/action-slack@v3.9.1
# uses: 8398a7/action-slack@v4.9.1
# with:
# status: ${{ job.status }}
# author_name: GitHub Actions # default: 8398a7@action-slack
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
- name: Cache Maven packages
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.m2
key: lucee-script-runner-m2-cache
- name: Cache Lucee files
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: _actions/lucee/script-runner/main/lucee-download-cache
key: lucee-downloads-${{ env.luceeVersion }}
Expand Down
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
jmimemagic.log
.exitcode
node_modules
.vscode
jmimemagic.log
.exitcode
node_modules
.vscode
package-lock.json

server/server-luceedocslocalserver.json
server-luceedocsbuilder.json
.commandbox
server/performance.log
server/performance.log
/commandbox-luceedocslocalserver
72 changes: 44 additions & 28 deletions api/data/DocTree.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,28 @@ component accessors=true {

private void function _initializeEmptyTree() {
setTree( [] );
setIdMap( {} );
setPathMap( {} );
setPageTypeMap( {} );
setRelatedMap( {} );
setCategoryMap( {} );
setReferenceMap( {} );
setDirectlyRelatedMap( {} );
setIdMap( [:] );
setPathMap( [:] );
setPageTypeMap( [:] );
setRelatedMap( [:] );
setCategoryMap( [:] );
setReferenceMap( [:] );
setDirectlyRelatedMap( [:] );
}

public void function updateTree() {
_updateTree();
}

public any function getPage( required string id ) {
if ( !pageExists( arguments.id ) )
systemOutput( "GetPage: #id# does not exist in doctree", true );
return variables.idMap[ arguments.id ] ?: NullValue();
}

public any function getPageByPath( required string path ) {
if ( !structKeyExists( variables.pathMap, arguments.path ) )
systemOutput( "GetPageByPath: #path# does not exist in doctree", true );
return variables.pathMap[ arguments.path ] ?: NullValue();
}

Expand Down Expand Up @@ -206,16 +210,19 @@ component accessors=true {
var start = getTickCount();
var _threads = getThreads();
each (q_source_files, function (page) {
// systemOutput( arguments.page.path & arguments.page.name, true);
var _parsedPage = new PageReader().preparePageObject( variables.rootDir, arguments.page.name, arguments.page.directory, arguments.page.path );

if ( ! _parsedPage.getHidden() ) {
variables.pageCache.addPage(
_parsedPage,
arguments.page.path
_parsedPage.getPath()
);
} else {
// systemOutput("hidden--------------------#arguments.page.path#", true)
}
}, (_threads != 1), _threads);
request.logger (text="Pages Parsed in #(getTickCount()-start)/1000#s");
request.logger (text=" #len(variables.pageCache.getPages())# Pages Parsed in #(getTickCount()-start)/1000#s");

_buildTreeHierachy(false);
_parseTree();
Expand Down Expand Up @@ -272,14 +279,16 @@ component accessors=true {
//var start = getTickCount();
var pages = variables.pageCache.getPages();
for (var pagePath in pages ){
var page = pages[pagePath].page;
if (arguments.reset)
var page = pages[ pagePath ].page;
if ( arguments.reset )
page.reset(); // clear previous structure data
try {
_addPageToTree(page);
_addPageToTree( page );
} catch (any e){
dump(page);
dump(e);
systemOutput( pagePath, true );
systemOutput( e, true );
echo(e);
abort;
}
Expand All @@ -290,16 +299,22 @@ component accessors=true {
private void function _parseTree( ) {
// expose guides as a top level folder
for (var folder in variables.tree){
if (folder.getId() eq "guides"){
var guideTree = folder.getChildren();
for (var guide in guideTree){
if (guide.getForceSortOrder() gt 0){
guide.setSortOrder(guide.getForceSortOrder());
} else {
guide.setSortOrder(6 + NumberFormat(guide.getSortOrder()/100,"0.00"));
switch( folder.getId() ){
case "guides":
var guideTree = folder.getChildren();
for (var guide in guideTree){
if (guide.getForceSortOrder() gt 0){
guide.setSortOrder(guide.getForceSortOrder());
} else {
guide.setSortOrder(6 + NumberFormat(guide.getSortOrder()/100,"0.00"));
}
variables.tree.append(guide);
}
variables.tree.append(guide);
}
break;
/*
case "recipes":
break;
*/
}
}
_sortChildren( variables.tree );
Expand All @@ -319,23 +334,24 @@ component accessors=true {
var isPage = arguments.page.isPage(); // workaround for page types not being parsed out correctly in PageReader.readPageFile

if ( !IsNull( parent ) ) {
if (isPage)
if ( isPage )
parent.addChild( arguments.page ); // don't add page subelements, i.e _attributes etc
arguments.page.setParent( parent );

ancestors = parent.getAncestors();
if (ancestors.len() eq 0 or pageType eq "_method") // avoid duplicates, hack for methods
if ( ancestors.len() eq 0 or pageType eq "_method" ) // avoid duplicates, hack for methods
ancestors.append( parent.getId() );
} else {
variables.tree.append( arguments.page );
}

if (not isPage)
throw "not a page"; // only add main pages
if ( !isPage ){
throw "not a page [#page.getFilePath()#]"; // only add main pages
}

if ( !StructKeyExists(variables.pageTypeMap, pageType) )
variables.pageTypeMap[pageType] = 0;
variables.pageTypeMap[pageType]++;
if ( !StructKeyExists( variables.pageTypeMap, pageType ) )
variables.pageTypeMap[ pageType ] = 0;
variables.pageTypeMap[ pageType ]++;

arguments.page.setAncestors( ancestors );
lineage = Duplicate( ancestors );
Expand Down
Loading

0 comments on commit 3d63b52

Please sign in to comment.