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_URL is the URL to access the host running Apache Tika.
|
||||
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();
|
||||
dotenvExpand.expand(process.env);
|
||||
// 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
|
||||
const port = process.env.PORT||3000;
|
||||
|
@ -240,16 +241,14 @@ app.get('/svg/*.svg', async (req, res) => {
|
|||
console.log(`Setting route for *`);
|
||||
app.get('*', async (req, res) => {
|
||||
await serve(req, res, {
|
||||
public: path.join(__dirname, '..', 'public'),
|
||||
public: publicPath,
|
||||
symlinks: true,
|
||||
trailingSlash: true,
|
||||
cleanUrls: false,
|
||||
renderSingle: false,
|
||||
unlisted: [
|
||||
".DS_Store",
|
||||
".git",
|
||||
"Thumbs.db",
|
||||
"README*",
|
||||
".*", //dot files/folders
|
||||
"Thumbs.db"
|
||||
],
|
||||
redirects: [
|
||||
{
|
||||
|
|
25
gulpfile.js
25
gulpfile.js
|
@ -13,7 +13,7 @@ const dotenvExpand = require('dotenv-expand');
|
|||
dotenv.config();
|
||||
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 defaultTikaUrl = 'http://tika:9998';
|
||||
|
@ -169,7 +169,7 @@ gulp.task('index:laws', async () => {
|
|||
];
|
||||
// Use glob to match files in the local directories
|
||||
let files = [];
|
||||
let cwd = path.resolve(__dirname, relPathToFiles.replaceAll('/', path.sep));
|
||||
let cwd = path.resolve(__dirname, publicPath.replaceAll('/', path.sep));
|
||||
globs.forEach(async (globPattern) => {
|
||||
files = files.concat(glob.globSync(globPattern, {
|
||||
cwd,
|
||||
|
@ -268,7 +268,7 @@ gulp.task('index:docs', async () => {
|
|||
];
|
||||
// Use glob to match files in the local directories
|
||||
let files = [];
|
||||
let cwd = path.resolve(__dirname, relPathToFiles.replaceAll('/', path.sep));
|
||||
let cwd = path.resolve(__dirname, publicPath.replaceAll('/', path.sep));
|
||||
globs.forEach(async (globPattern) => {
|
||||
files = files.concat(glob.globSync(globPattern, {
|
||||
cwd,
|
||||
|
@ -358,6 +358,15 @@ gulp.task('index:docs', async () => {
|
|||
// 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
|
||||
// Index the file with its text content and metadata
|
||||
console.log(`Indexing ${url}`);
|
||||
|
@ -366,6 +375,16 @@ gulp.task('index:docs', async () => {
|
|||
// Continue
|
||||
console.log(`Done.`);
|
||||
} 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
|
||||
console.log(`Skipping file '${file}' as metadata matches existing metadata in Solr index.`);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user