Skip to content

Commit

Permalink
Merge pull request #21 from bouvet-apps/feature/check-master-branch
Browse files Browse the repository at this point in the history
Feature/check master branch
  • Loading branch information
vi-h authored Oct 17, 2022
2 parents 928156a + e6641e1 commit df12d91
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 88 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ If you are running HTTPS and you are met with `failed: Error during WebSocket ha
Not tested for below 6.12.0

## Changelog
### Version 3.1.0
* Possible to choose to check master brach
* Added HTTP status messages to result (including report)
* Added information about how the cache works in the "Tips and information" box
* Can start linkChecker again without refreshing browser if we get error from websocket

### Version 3.0.1
* Fixed bug with valid external links being listed as "Need manual review".
* Fixed bug with internal links always being listed twice.
Expand Down
Binary file modified dist/linkchecker.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ displayName = LinkChecker
vendorName = Bouvet Norge AS
vendorUrl = https://www.bouvet.no
xpVersion = 7.9.0
version = 3.0.1
version = 3.1.0
45 changes: 34 additions & 11 deletions src/main/resources/admin/widgets/link-checker/link-checker.es6
Original file line number Diff line number Diff line change
Expand Up @@ -20,35 +20,47 @@ exports.get = (req) => {
};
}

const content = libs.content.get({ key: contentId });

let publishedContent = false;
if (content?.publish?.from) {
// Content exist in master branch
publishedContent = true;
}

let url = libs.portal.serviceUrl({
service: "link-checker",
type: "absolute",
params: {
contentId,
repository: req.params.repository,
branch: "draft"
repository: req.params.repository
}
});
url = url.replace(/^http:\/\//i, "ws://");
url = url.replace(/^https:\/\//i, "wss://");

const widgetScriptUrl = libs.portal.assetUrl({ path: "js/widget.js" });

const locale = libs.content.get({ key: contentId })?.language || 'no';
const locale = content?.language || 'no';

const model = {
serviceUrl: url,
key: contentId,
widgetScriptUrl,
publishedContent,
locale,
/**
* @phrases ["widgets.link-checker.info", "widgets.link-checker.start", "widgets.link-checker.radio-legend", "widgets.link-checker.radio-this-content",
* "widgets.link-checker.radio-child-content", "widgets.link-checker.radio-both", "widgets.link-checker.stop", "widgets.link-checker.download-report",
* "widgets.link-checker.loading", "widgets.link-checker.timeout", "widgets.link-checker.manual-review", "widgets.link-checker.broken-link",
* "widgets.link-checker.broken-links", "widgets.link-checker.report", "widgets.link-checker.found", "widgets.link-checker.invalid-link", "widgets.link-checker.invalid-links",
* "widgets.link-checker.download-more", "widgets.link-checker.no-broken-links", "widgets.link-checker.tips-and-info", "widgets.link-checker.draft-checked-tip",
* "widgets.link-checker.loading","widgets.link-checker.from", "widgets.link-checker.draft-explanation", "widgets.link-checker.master-explanation",
* "widgets.link-checker.explanation-title",
*
* "widgets.link-checker.manual-review", "widgets.link-checker.broken-link", "widgets.link-checker.broken-links", "widgets.link-checker.report",
* "widgets.link-checker.found", "widgets.link-checker.invalid-link", "widgets.link-checker.invalid-links",
* "widgets.link-checker.download-more", "widgets.link-checker.no-broken-links", "widgets.link-checker.tips-and-info",
* "widgets.link-checker.internal-content-links-tip", "widgets.link-checker.common-cause-internal-tip", "widgets.link-checker.target-content-deleted-tip",
* "widgets.link-checker.content-imported-tip"]
* "widgets.link-checker.content-imported-tip", "widgets.link-checker.content-not-found-tip", "widgets.link-checker.cache-tip",
* "http403", "http404", "http408", "http500", "http503", "status-code", "status-message"]
*/
localized: {
info: libs.i18n.localize({ key: "widgets.link-checker.info", locale }),
Expand All @@ -59,10 +71,13 @@ exports.get = (req) => {
radioBoth: libs.i18n.localize({ key: "widgets.link-checker.radio-both", locale }),
stop: libs.i18n.localize({ key: "widgets.link-checker.stop", locale }),
downloadReport: libs.i18n.localize({ key: "widgets.link-checker.download-report", locale }),
loading: libs.i18n.localize({ key: "widgets.link-checker.loading", locale })
loading: libs.i18n.localize({ key: "widgets.link-checker.loading", locale }),
from: libs.i18n.localize({ key: "widgets.link-checker.from", locale }),
draftExplanation: libs.i18n.localize({ key: "widgets.link-checker.draft-explanation", locale }),
masterExplanation: libs.i18n.localize({ key: "widgets.link-checker.master-explanation", locale }),
explanationTitle: libs.i18n.localize({ key: "widgets.link-checker.explanation-title", locale })
},
localizedString: JSON.stringify({
timeout: libs.i18n.localize({ key: "widgets.link-checker.timeout", locale }),
manualReview: libs.i18n.localize({ key: "widgets.link-checker.manual-review", locale }),
brokenLink: libs.i18n.localize({ key: "widgets.link-checker.broken-link", locale }),
brokenLinks: libs.i18n.localize({ key: "widgets.link-checker.broken-links", locale }),
Expand All @@ -73,11 +88,19 @@ exports.get = (req) => {
downloadMore: libs.i18n.localize({ key: "widgets.link-checker.download-more", locale }),
noBrokenLinks: libs.i18n.localize({ key: "widgets.link-checker.no-broken-links", locale }),
tipsAndInfo: libs.i18n.localize({ key: "widgets.link-checker.tips-and-info", locale }),
draftCheckedTip: libs.i18n.localize({ key: "widgets.link-checker.draft-checked-tip", locale }),
internalContentLinksTip: libs.i18n.localize({ key: "widgets.link-checker.internal-content-links-tip", locale }),
commonCauseInternalTip: libs.i18n.localize({ key: "widgets.link-checker.common-cause-internal-tip", locale }),
targetContentDeletedTip: libs.i18n.localize({ key: "widgets.link-checker.target-content-deleted-tip", locale }),
contentImportedTip: libs.i18n.localize({ key: "widgets.link-checker.content-imported-tip", locale })
contentImportedTip: libs.i18n.localize({ key: "widgets.link-checker.content-imported-tip", locale }),
contentNotFoundTip: libs.i18n.localize({ key: "widgets.link-checker.content-not-found-tip", locale }),
cacheTip: libs.i18n.localize({ key: "widgets.link-checker.cache-tip", locale }),
http403: libs.i18n.localize({ key: "http403", locale }),
http404: libs.i18n.localize({ key: "http404", locale }),
http408: libs.i18n.localize({ key: "http408", locale }),
http500: libs.i18n.localize({ key: "http500", locale }),
http503: libs.i18n.localize({ key: "http503", locale }),
statusCode: libs.i18n.localize({ key: "status-code", locale }),
statusMessage: libs.i18n.localize({ key: "status-message", locale })
})
};

Expand Down
36 changes: 25 additions & 11 deletions src/main/resources/admin/widgets/link-checker/link-checker.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
<form id="link-checker__form" data-th-if="${serviceUrl}" method="get" data-th-data-action="${serviceUrl}" data-th-data-localized-elements="${localizedString}" data-th-data-locale="${locale}">
<input type="hidden" data-th-if="${key}" data-th-value="${key}" id="contentId"/>
<div class="link-checker__start">
<button id="btn-start" value="Start" data-th-text="${localized.start}">Start</button>
<div class="selection-radios">
<fieldset>
<legend data-th-text="${localized.radioLegend}">Check</legend>
Expand All @@ -31,19 +30,24 @@
<label for="both" data-th-text="${localized.radioBoth}">Both</label>
</div>
</fieldset>
<fieldset>
<legend data-th-text="${localized.from}">From</legend>
<div>
<input type="radio" id="draft" name="branch" value="draft" checked/>
<label for="draft">Draft <button id="draft-btn" class="question-btn" data-th-title="${explanationTitle}"><svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 24 24" width="16px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"/></svg></button></label>
<p data-th-text="${localized.draftExplanation}" id="draft-explanation" style="display: none;">Checks the latest updated version of the content, which may or may not be the published version</p>
</div>
<div>
<input data-th-if="${publishedContent}" type="radio" id="master" name="branch" value="master"/>
<input data-th-unless="${publishedContent}" type="radio" name="branch" value="master" disabled/>
<label for="master" data-th-classappend="${publishedContent} ? content-published : content-disabled">Master <button id="master-btn" class="question-btn" data-th-title="${explanationTitle}"><svg xmlns="http://www.w3.org/2000/svg" height="16px" viewBox="0 0 24 24" width="16px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"/></svg></button></label>
<p data-th-text="${localized.masterExplanation}" id="master-explanation" style="display: none;">Checks only the published version of the content, which will not include new, scheduled, modified or unpublished versions</p>
</div>
</fieldset>
</div>
<button id="btn-start" value="Start" data-th-text="${localized.start}">Start</button>
</div>
</form>
<button id="btn-stop" style="display: none;" value="STOP" data-th-text="${localized.stop}">STOP</button>
<button id="btn-download" style="display: none;" value="CSV">
<div class="aligned-center">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF">
<g><rect fill="none" height="24" width="24"/></g>
<g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g>
</svg>
<span data-th-text="${localized.downloadReport}">Download report (.csv)</span>
</div>
</button>
<div class="link-checker__progress">
<div class="progress-indicator__container">
<div class="progress-indicator__counter" data-th-text="${localized.loading}">Loading...</div>
Expand All @@ -58,6 +62,16 @@
</div>
<div class="link-checker__status"></div>
</div>
<button id="btn-stop" style="display: none;" value="STOP" data-th-text="${localized.stop}">STOP</button>
<button id="btn-download" style="display: none;" value="CSV">
<div class="aligned-center">
<svg xmlns="http://www.w3.org/2000/svg" enable-background="new 0 0 24 24" height="24px" viewBox="0 0 24 24" width="24px" fill="#FFFFFF">
<g><rect fill="none" height="24" width="24"/></g>
<g><path d="M18,15v3H6v-3H4v3c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2v-3H18z M17,11l-1.41-1.41L13,12.17V4h-2v8.17L8.41,9.59L7,11l5,5 L17,11z"/></g>
</svg>
<span data-th-text="${localized.downloadReport}">Download report (.csv)</span>
</div>
</button>
<br>
</div>
<div id="link-checker__result"></div>
Expand Down
111 changes: 86 additions & 25 deletions src/main/resources/assets/css/app.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.link-checker {
text-align: center;
background: white;
-webkit-box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
padding-top: 1rem;
}

.link-checker__info p {
max-width: 270px;
margin: auto;
margin: 0 0.5rem;
}

.link-checker button {
margin: 0 0.5rem;
width: calc(100% - 1rem);
text-align: center;
}

.link-checker__tips p {
Expand Down Expand Up @@ -61,7 +65,7 @@ h5.success-text {
}

#btn-download {
margin: 1rem 0;
margin: 1rem 0.5rem;
border:none;
color: #fdfdfd;
background-color: rgb(24, 135, 50);
Expand All @@ -71,13 +75,18 @@ h5.success-text {
cursor: pointer;
}

#btn-download:focus, #btn-download:hover {
background-color: rgb(149 176 155);
}

#btn-download .aligned-center {
display: flex;
align-items: center;
display: flex;
align-items: center;
justify-content: center;
}

#btn-download .aligned-center svg {
margin-right: 5px;
margin-right: 5px;
}

#btn-stop {
Expand All @@ -91,25 +100,14 @@ h5.success-text {
cursor: pointer;
}

#btn-stop:focus, #btn-stop:hover {
background-color: #d56363;
}

.link-checker__start {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-ms-flex-direction: row;
flex-direction: row;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
margin: 0.5rem 0;
}


#btn-start {
color: #fff;
background-color: #2663b8;
Expand All @@ -118,28 +116,75 @@ h5.success-text {
border-radius: 22px;
font-size: 15px;
cursor: pointer;
margin-right: 0.5rem;
margin-top: 5px;
}

#btn-start:focus, #btn-start:hover {
background-color: #678ec5;
}


/* ------------- Radio buttons ------------- */

.selection-radios {
text-align: left;
margin-left: 0.5rem;
margin: 0 0.5rem;
width: calc(100% - 1rem);
}

.selection-radios legend {
width: 100%;
text-align: center;
border-bottom: 1px solid #2663b8;
padding-bottom: 0.2rem;
}

.selection-radios label {
display: inline-flex;
}

.selection-radios .question-btn {
display: inline;
width: fit-content;
background: transparent;
border: 0;
padding: 0;
margin: 0 0 1px 5px;
cursor: pointer;
outline: 0;
}

.selection-radios .question-btn:focus, .selection-radios .question-btn:hover {
border-bottom: 1px solid;
margin: 0 0 0 5px;
}

.selection-radios input[type="radio"] {
margin-top: -3px;
vertical-align: middle;
}

.selection-radios fieldset {
margin-top: 5px;
}

.selection-radios fieldset div {
margin: 0.4rem 0;
}

.selection-radios .content-disabled {
color: #575555;
}

.selection-radios em {
font-style: italic;
}

.selection-radios p {
margin: 5px 0;
color: #575555;
font-style: italic;
}

/* ------------- Circle progress bar ------------- */

.progress-indicator__container {
Expand Down Expand Up @@ -203,13 +248,28 @@ circle#progress-indicator__bar, circle#progress-indicator__next {

.widget-view.internal-widget.success {
margin: 10px;
text-align: center;
background: white;
-webkit-box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
padding: 10px;
}

.widget-view.external-widget .widget-item-view .widget-view.internal-widget.error {
margin: 10px;
background-color: #d40000;
-webkit-box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
box-shadow: 0px 1px 2px 1px rgba(0, 0, 0, 0.1);
padding: 10px;
position: relative;
width: auto;
}

.widget-view.internal-widget.error .broken-links-error h3 {
line-height: 20px;
font-size: 18px;
padding: 0;
}


.broken-links-error h3{
background-color: #d40000;
Expand Down Expand Up @@ -260,6 +320,7 @@ circle#progress-indicator__bar, circle#progress-indicator__next {
}

.broken-links-error__link__target {
color: #d40000;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
Expand Down
Loading

0 comments on commit df12d91

Please sign in to comment.