forked from nm3clol/nm3clol-express-app
Added PUBLIC_DIR environment variable.
This commit is contained in:
parent
ee411d5ce2
commit
84d2081072
|
@ -40,3 +40,6 @@ TIKA_HOST="tika"
|
||||||
TIKA_PORT=9998
|
TIKA_PORT=9998
|
||||||
# TIKA_URL is the URL to access the host running Apache Tika.
|
# TIKA_URL is the URL to access the host running Apache Tika.
|
||||||
TIKA_URL="http://${TIKA_HOST}:${TIKA_PORT}"
|
TIKA_URL="http://${TIKA_HOST}:${TIKA_PORT}"
|
||||||
|
|
||||||
|
# PUBLIC_DIR is the directory relative to this project root for the public files
|
||||||
|
PUBLIC_DIR="../nm3clol-public"
|
||||||
|
|
|
@ -14,6 +14,7 @@ const dotenvExpand = require('dotenv-expand');
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
dotenvExpand.expand(process.env);
|
dotenvExpand.expand(process.env);
|
||||||
// const advancedSearch = require('../routes/advanced-search');
|
// const advancedSearch = require('../routes/advanced-search');
|
||||||
|
const publicPath = path.join(__dirname, '..', process.env.PUBLIC_DIR.replaceAll('\\', path.sep).replaceAll('/', path.sep));
|
||||||
|
|
||||||
// Port number for HTTP server
|
// Port number for HTTP server
|
||||||
const port = process.env.PORT||3000;
|
const port = process.env.PORT||3000;
|
||||||
|
@ -240,16 +241,14 @@ app.get('/svg/*.svg', async (req, res) => {
|
||||||
console.log(`Setting route for *`);
|
console.log(`Setting route for *`);
|
||||||
app.get('*', async (req, res) => {
|
app.get('*', async (req, res) => {
|
||||||
await serve(req, res, {
|
await serve(req, res, {
|
||||||
public: path.join(__dirname, '..', 'public'),
|
public: publicPath,
|
||||||
symlinks: true,
|
symlinks: true,
|
||||||
trailingSlash: true,
|
trailingSlash: true,
|
||||||
cleanUrls: false,
|
cleanUrls: false,
|
||||||
renderSingle: false,
|
renderSingle: false,
|
||||||
unlisted: [
|
unlisted: [
|
||||||
".DS_Store",
|
".*", //dot files/folders
|
||||||
".git",
|
"Thumbs.db"
|
||||||
"Thumbs.db",
|
|
||||||
"README*",
|
|
||||||
],
|
],
|
||||||
redirects: [
|
redirects: [
|
||||||
{
|
{
|
||||||
|
|
25
gulpfile.js
25
gulpfile.js
|
@ -13,7 +13,7 @@ const dotenvExpand = require('dotenv-expand');
|
||||||
dotenv.config();
|
dotenv.config();
|
||||||
dotenvExpand.expand(process.env);
|
dotenvExpand.expand(process.env);
|
||||||
|
|
||||||
const relPathToFiles = './public';
|
const publicPath = path.join(__dirname, '..', process.env.PUBLIC_DIR.replaceAll('\\', path.sep).replaceAll('/', path.sep));
|
||||||
|
|
||||||
const defaultSiteUrl = 'http://localhost';
|
const defaultSiteUrl = 'http://localhost';
|
||||||
const defaultTikaUrl = 'http://tika:9998';
|
const defaultTikaUrl = 'http://tika:9998';
|
||||||
|
@ -169,7 +169,7 @@ gulp.task('index:laws', async () => {
|
||||||
];
|
];
|
||||||
// Use glob to match files in the local directories
|
// Use glob to match files in the local directories
|
||||||
let files = [];
|
let files = [];
|
||||||
let cwd = path.resolve(__dirname, relPathToFiles.replaceAll('/', path.sep));
|
let cwd = path.resolve(__dirname, publicPath.replaceAll('/', path.sep));
|
||||||
globs.forEach(async (globPattern) => {
|
globs.forEach(async (globPattern) => {
|
||||||
files = files.concat(glob.globSync(globPattern, {
|
files = files.concat(glob.globSync(globPattern, {
|
||||||
cwd,
|
cwd,
|
||||||
|
@ -268,7 +268,7 @@ gulp.task('index:docs', async () => {
|
||||||
];
|
];
|
||||||
// Use glob to match files in the local directories
|
// Use glob to match files in the local directories
|
||||||
let files = [];
|
let files = [];
|
||||||
let cwd = path.resolve(__dirname, relPathToFiles.replaceAll('/', path.sep));
|
let cwd = path.resolve(__dirname, publicPath.replaceAll('/', path.sep));
|
||||||
globs.forEach(async (globPattern) => {
|
globs.forEach(async (globPattern) => {
|
||||||
files = files.concat(glob.globSync(globPattern, {
|
files = files.concat(glob.globSync(globPattern, {
|
||||||
cwd,
|
cwd,
|
||||||
|
@ -358,6 +358,15 @@ gulp.task('index:docs', async () => {
|
||||||
// Add additional fields as needed (e.g., title, author, etc.)
|
// Add additional fields as needed (e.g., title, author, etc.)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Save a copy of the text into a file
|
||||||
|
fs.writeFileSync(fileFullPath + ".tika.g.txt", extractedText, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error writing to file', err);
|
||||||
|
} else {
|
||||||
|
console.log(`File ${fileName} has been written successfully!`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Send document to Solr for indexing
|
// Send document to Solr for indexing
|
||||||
// Index the file with its text content and metadata
|
// Index the file with its text content and metadata
|
||||||
console.log(`Indexing ${url}`);
|
console.log(`Indexing ${url}`);
|
||||||
|
@ -366,6 +375,16 @@ gulp.task('index:docs', async () => {
|
||||||
// Continue
|
// Continue
|
||||||
console.log(`Done.`);
|
console.log(`Done.`);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('metadata:', metadata);
|
||||||
|
// Save a copy of the text into a file
|
||||||
|
fs.writeFileSync(fileFullPath + ".tika.g.txt", extractedText, (err) => {
|
||||||
|
if (err) {
|
||||||
|
console.error('Error writing to file', err);
|
||||||
|
} else {
|
||||||
|
console.log(`File ${fileName} has been written successfully!`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Metadata matches, skip the file
|
// Metadata matches, skip the file
|
||||||
console.log(`Skipping file '${file}' as metadata matches existing metadata in Solr index.`);
|
console.log(`Skipping file '${file}' as metadata matches existing metadata in Solr index.`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user