Skip to content

Commit

Permalink
Merge 0a06368 into f1db0c0
Browse files Browse the repository at this point in the history
  • Loading branch information
MarieVerdonck committed Aug 12, 2020
2 parents f1db0c0 + 0a06368 commit 5d264a7
Show file tree
Hide file tree
Showing 13 changed files with 242 additions and 162 deletions.
7 changes: 4 additions & 3 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig": {
"path": "./webpack/webpack.common.ts",
"path": "./webpack/webpack.browser.ts",
"mergeStrategies": {
"loaders": "prepend"
}
Expand All @@ -30,7 +30,8 @@
"tsConfig": "tsconfig.app.json",
"aot": false,
"assets": [
"src/assets"
"src/assets",
"src/robots.txt"
],
"styles": [
"src/styles.scss"
Expand Down Expand Up @@ -84,7 +85,7 @@
"builder": "@angular-builders/custom-webpack:karma",
"options": {
"customWebpackConfig": {
"path": "./webpack/webpack.common.ts",
"path": "./webpack/webpack.test.ts",
"mergeStrategies": {
"loaders": "prepend"
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"dotenv": "^8.2.0",
"fork-ts-checker-webpack-plugin": "^0.4.10",
"html-webpack-plugin": "^3.2.0",
"http-proxy-middleware": "^1.0.5",
"jasmine-core": "^3.3.0",
"jasmine-marbles": "0.3.1",
"jasmine-spec-reporter": "~4.2.1",
Expand Down
20 changes: 19 additions & 1 deletion scripts/set-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ import(environmentFilePath)
function generateEnvironmentFile(file: GlobalConfig): void {
file.production = production;
buildBaseUrls(file);

// TODO remove workaround in beta 5
if (file.rest.nameSpace.match("(.*)/api/?$") !== null) {
const newValue = getNameSpace(file.rest.nameSpace);
console.log(colors.white.bgMagenta.bold(`The rest.nameSpace property in your environment file or in your DSPACE_REST_NAMESPACE environment variable ends with '/api'.\nThis is deprecated. As '/api' isn't configurable on the rest side, it shouldn't be repeated in every environment file.\nPlease change the rest nameSpace to '${newValue}'`));
}

const contents = `export const environment = ` + JSON.stringify(file);
writeFile(targetPath, contents, (err) => {
if (err) {
Expand Down Expand Up @@ -112,5 +119,16 @@ function getPort(port: number): string {
}

function getNameSpace(nameSpace: string): string {
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
// TODO remove workaround in beta 5
const apiMatches = nameSpace.match("(.*)/api/?$");
if (apiMatches != null) {
let newValue = '/'
if (hasValue(apiMatches[1])) {
newValue = apiMatches[1];
}
return newValue;
}
else {
return nameSpace ? nameSpace.charAt(0) === '/' ? nameSpace : '/' + nameSpace : '';
}
}
6 changes: 6 additions & 0 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { enableProdMode, NgModuleFactory, Type } from '@angular/core';

import { REQUEST, RESPONSE } from '@nguniversal/express-engine/tokens';
import { environment } from './src/environments/environment';
import { createProxyMiddleware } from 'http-proxy-middleware';

/*
* Set path for the browser application's dist folder
Expand Down Expand Up @@ -106,6 +107,11 @@ app.set('view engine', 'html');
*/
app.set('views', DIST_FOLDER);

/**
* Proxy the sitemaps
*/
app.use('/sitemap**', createProxyMiddleware({ target: `${environment.rest.baseUrl}/sitemaps`, changeOrigin: true }));

/*
* Adds a cache control header to the response
* The cache control value can be configured in the environments file and defaults to max-age=60
Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/hal-endpoint.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('HALEndpointService', () => {
describe('getRootEndpointMap', () => {
it('should configure a new EndpointMapRequest', () => {
(service as any).getRootEndpointMap();
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl);
const expected = new EndpointMapRequest(requestService.generateRequestId(), environment.rest.baseUrl + '/api');
expect(requestService.configure).toHaveBeenCalledWith(expected);
});

Expand Down
2 changes: 1 addition & 1 deletion src/app/core/shared/hal-endpoint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class HALEndpointService {
}

protected getRootHref(): string {
return new RESTURLCombiner('/').toString();
return new RESTURLCombiner('/api').toString();
}

protected getRootEndpointMap(): Observable<EndpointMap> {
Expand Down
151 changes: 151 additions & 0 deletions src/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# The URL to the DSpace sitemaps
# XML sitemap is listed first as it is preferred by most search engines
Sitemap: /sitemap_index.xml
Sitemap: /sitemap_index.html

##########################
# Default Access Group
# (NOTE: blank lines are not allowable in a group record)
##########################
User-agent: *
# Disable access to Discovery search and filters; admin pages; processes; submission; workspace; workflow & profile page
Disallow: /search
Disallow: /admin/*
Disallow: /processes
Disallow: /submit
Disallow: /workspaceitems
Disallow: /profile
Disallow: /workflowitems

# Optionally uncomment the following line ONLY if sitemaps are working
# and you have verified that your site is being indexed correctly.
# Disallow: /browse/*
#
# If you have configured DSpace (Solr-based) Statistics to be publicly
# accessible, then you may not want this content to be indexed
# Disallow: /statistics
#
# You also may wish to disallow access to the following paths, in order
# to stop web spiders from accessing user-based content
# Disallow: /contact
# Disallow: /feedback
# Disallow: /forgot
# Disallow: /login
# Disallow: /register


##############################
# Section for misbehaving bots
# The following directives to block specific robots were borrowed from Wikipedia's robots.txt
##############################

# advertising-related bots:
User-agent: Mediapartners-Google*
Disallow: /

# Crawlers that are kind enough to obey, but which we'd rather not have
# unless they're feeding search engines.
User-agent: UbiCrawler
Disallow: /

User-agent: DOC
Disallow: /

User-agent: Zao
Disallow: /

# Some bots are known to be trouble, particularly those designed to copy
# entire sites. Please obey robots.txt.
User-agent: sitecheck.internetseer.com
Disallow: /

User-agent: Zealbot
Disallow: /

User-agent: MSIECrawler
Disallow: /

User-agent: SiteSnagger
Disallow: /

User-agent: WebStripper
Disallow: /

User-agent: WebCopier
Disallow: /

User-agent: Fetch
Disallow: /

User-agent: Offline Explorer
Disallow: /

User-agent: Teleport
Disallow: /

User-agent: TeleportPro
Disallow: /

User-agent: WebZIP
Disallow: /

User-agent: linko
Disallow: /

User-agent: HTTrack
Disallow: /

User-agent: Microsoft.URL.Control
Disallow: /

User-agent: Xenu
Disallow: /

User-agent: larbin
Disallow: /

User-agent: libwww
Disallow: /

User-agent: ZyBORG
Disallow: /

User-agent: Download Ninja
Disallow: /

# Misbehaving: requests much too fast:
User-agent: fast
Disallow: /

#
# If your DSpace is going down because of someone using recursive wget,
# you can activate the following rule.
#
# If your own faculty is bringing down your dspace with recursive wget,
# you can advise them to use the --wait option to set the delay between hits.
#
#User-agent: wget
#Disallow: /

#
# The 'grub' distributed client has been *very* poorly behaved.
#
User-agent: grub-client
Disallow: /

#
# Doesn't follow robots.txt anyway, but...
#
User-agent: k2spider
Disallow: /

#
# Hits many times per second, not acceptable
# http://www.nameprotect.com/botinfo.html
User-agent: NPBot
Disallow: /

# A capture bot, downloads gazillions of pages with no public benefit
# http://www.webreaper.net/
User-agent: WebReaper
Disallow: /
45 changes: 0 additions & 45 deletions webpack.config.ts

This file was deleted.

8 changes: 8 additions & 0 deletions webpack/webpack.browser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { commonExports } from './webpack.common';

module.exports = Object.assign({}, commonExports, {
target: 'web',
node: {
module: 'empty'
}
});
11 changes: 4 additions & 7 deletions webpack/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ export const copyWebpackOptions = [
}, {
from: path.join(__dirname, '..', 'src', 'assets', 'i18n'),
to: path.join('assets', 'i18n')
}, {
from: path.join(__dirname, '..', 'src', 'robots.txt'),
to: path.join('robots.txt')
}
];
];

export const commonExports = {
target: 'web',
plugins: [
new CopyWebpackPlugin(copyWebpackOptions),
new HtmlWebpackPlugin({
Expand All @@ -37,9 +39,6 @@ export const commonExports = {
defaultAttribute: 'defer'
})
],
node: {
module: 'empty'
},
module: {
rules: [
{
Expand Down Expand Up @@ -99,5 +98,3 @@ export const commonExports = {
],
}
};

module.exports = commonExports;

0 comments on commit 5d264a7

Please sign in to comment.