Skip to content
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

Make PlantUML server base address configurable #25

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ const generateCompleteMD = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(pumlFile.content, options);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down Expand Up @@ -231,7 +231,7 @@ const generateCompletePDF = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(pumlFile.content, options);

let diagramImage = `![diagram](${diagramUrl})`;

Expand Down Expand Up @@ -362,7 +362,7 @@ const generateMD = async (tree, options, onProgress) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(pumlFile.content, options);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down Expand Up @@ -423,7 +423,7 @@ const generatePDF = async (tree, options, onProgress) => {
MD += '\n\n';
let diagramUrl = encodeURIPath(path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`);
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(pumlFile.content, options);

let diagramImage = `![diagram](${diagramUrl})`;

Expand Down Expand Up @@ -523,7 +523,7 @@ const generateWebMD = async (tree, options) => {
path.parse(pumlFile.dir).name + `.${options.DIAGRAM_FORMAT}`
));
if (!options.GENERATE_LOCAL_IMAGES)
diagramUrl = plantUmlServerUrl(pumlFile.content);
diagramUrl = plantUmlServerUrl(pumlFile.content, options);

let diagramImage = `![diagram](${diagramUrl})`;
let diagramLink = `[Go to ${path.parse(pumlFile.dir).name} diagram](${diagramUrl})`;
Expand Down
10 changes: 10 additions & 0 deletions cli.collect.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,14 @@ module.exports = async (currentConfiguration, conf, program) => {
});
conf.set('charset', responses.charset);
}

if (!currentConfiguration.SERVER_BASE_ADDRESS || program.config) {
responses = await inquirer.prompt({
type: 'input',
name: 'plantUmlServerBaseAddress',
message: 'Change server base address',
default: currentConfiguration.SERVER_BASE_ADDRESS || 'https://www.plantuml.com/plantuml/'
});
conf.set('plantUmlServerBaseAddress', responses.plantUmlServerBaseAddress);
}
};
2 changes: 2 additions & 0 deletions cli.help.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,7 @@ ${chalk.cyan('Include breadcrumbs')}
Shows the original folder hierarchy after each title.
${chalk.cyan('Place diagrams before text')}
Choose to place diagrams before or after the text.
${chalk.cyan('Use external PlantUML server')}
Change the PlantUML server.
`);
};
3 changes: 2 additions & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ const getOptions = conf => {
HAS_RUN: conf.get('hasRun'),
MD_FILE_NAME: 'README',
WEB_FILE_NAME: 'HOME',
DIAGRAM_FORMAT: 'svg'
DIAGRAM_FORMAT: 'svg',
SERVER_BASE_ADDRESS: conf.get('plantUmlServerBaseAddress')
}
};

Expand Down
1 change: 1 addition & 0 deletions cli.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Generate diagram images locally: ${currentConfiguration.GENERATE_LOCAL_IMAGES !=
Replace diagrams with a link: ${currentConfiguration.INCLUDE_LINK_TO_DIAGRAM !== undefined ? chalk.green(currentConfiguration.INCLUDE_LINK_TO_DIAGRAM) : chalk.red('not set')}
Place diagrams before text: ${currentConfiguration.DIAGRAMS_ON_TOP !== undefined ? chalk.green(currentConfiguration.DIAGRAMS_ON_TOP) : chalk.red('not set')}
Charset: ${currentConfiguration.CHARSET !== undefined ? chalk.green(currentConfiguration.CHARSET) : chalk.red('not set')}
PlantUml server base address: ${currentConfiguration.SERVER_BASE_ADDRESS !== undefined ? chalk.green(currentConfiguration.SERVER_BASE_ADDRESS) : chalk.red('not set')}
`);
return;
};
2 changes: 1 addition & 1 deletion utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const urlTextFrom = (s) => {
}
};

const plantUmlServerUrl = content => `https://www.plantuml.com/plantuml/svg/0/${urlTextFrom(content)}`;
const plantUmlServerUrl = (content, options) => `${options.SERVER_BASE_ADDRESS}svg/0/${urlTextFrom(content)}`;

const clearConsole = () => {
process.stdout.write('\x1b[2J');
Expand Down