Skip to content

Commit

Permalink
Merge pull request #181 from cfengine/master
Browse files Browse the repository at this point in the history
Align production with master
  • Loading branch information
aleksandrychev authored Oct 7, 2024
2 parents 32d681e + 2b89e67 commit f881a64
Show file tree
Hide file tree
Showing 23 changed files with 474 additions and 230 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bump-hugo-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
sed -i "s|https://github.com/gohugoio/hugo/releases/download/v.*_Linux-64bit.tar.gz|https://github.com/gohugoio/hugo/releases/download/v${{ steps.fetch_hugo_version.outputs.version }}/hugo_${{ steps.fetch_hugo_version.outputs.version }}_Linux-64bit.tar.gz|" Dockerfile
sed -i "s/.*sha256sum.*/RUN echo \"${{ steps.fetch_hugo_version.outputs.checksum }} hugo.tar.gz\" | sha256sum -c/" Dockerfile
- name: Create Pull Request
uses: cfengine/create-pull-request@v6
uses: cfengine/create-pull-request@v7
with:
commit-message: Upgraded Hugo version to ${{ steps.fetch_hugo_version.outputs.version }}
title: Upgraded Hugo version to ${{ steps.fetch_hugo_version.outputs.version }}
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
FROM node:18-alpine AS build
ARG GITHUB_USERNAME_TOKEN
WORKDIR /build-website
ADD https://github.com/gohugoio/hugo/releases/download/v0.124.1/hugo_0.124.1_Linux-64bit.tar.gz hugo.tar.gz
RUN echo "b2b20fea637bc2a1e98b7ac93da0e4bb39ebb45ea73f261efb0de0a6f3ea87fd hugo.tar.gz" | sha256sum -c
ADD https://github.com/gohugoio/hugo/releases/download/v0.135.0/hugo_0.135.0_Linux-64bit.tar.gz hugo.tar.gz
RUN echo "ba6adcca5bb8ea899f712bfa5734c91602ed17eae31917919ca40547853b1394 hugo.tar.gz" | sha256sum -c
RUN tar -zxvf hugo.tar.gz
COPY package-lock.json package.json ./
RUN npm ci
Expand Down
15 changes: 12 additions & 3 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,18 @@ const modulesUpdate = async () => {
} else {
content = 'Readme not found';
}

const discussionParams = new URLSearchParams({
category: 'modules',
title: index,
body: 'I have a question regarding...'
})
const discussionSearch = new URLSearchParams({
discussions_q: `is:open category:Modules ${index}`
})
// frontmatters
let frontmatter = {
title: index,
date: new Date(version.timestamp).toLocaleString(),
date: new Date(version.timestamp),
id: index,
description: module.description || '',
author: {
Expand All @@ -112,7 +119,9 @@ const modulesUpdate = async () => {
commit: module.commit,
dependencies: module.dependencies || [],
tags: module.tags || [],
layout: 'single'
layout: 'single',
discussion: `https://github.com/cfengine/core/discussions/new?${discussionParams.toString()}`,
discussionSearch: `https://github.com/cfengine/core/discussions/categories/modules?${discussionSearch.toString()}`
};

if (module.hasOwnProperty('version')) {
Expand Down
5 changes: 4 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ theme = "cfbs-theme"
# Number of posts per page
Paginate = 10
enableRobotsTXT = true
disqusShortname = 'cfengine-build'
syntaxCSS = true

[params.info]
homeTitle = "CFEngine Build" # Title for home page
Expand All @@ -20,3 +20,6 @@ author = "author"

[params.sitemap]
baseUrl = "https://build.cfengine.com"
[markup]
[markup.highlight]
noClasses = false
2 changes: 1 addition & 1 deletion content/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h1>Welcome to CFEngine Build</h1>
</div>
</div>
</section>
<section class="followed" style="display: none;">
<section class="followed display-none">
<div class="container">
<h2>Updates for the modules you follow</h2>
<div class="followed-subtitle">
Expand Down
2 changes: 2 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ http {
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains" always;
add_header X-Content-Type-Options "nosniff" always;
add_header 'Referrer-Policy' 'strict-origin';
add_header Content-Security-Policy "default-src 'none'; style-src 'self' cdn.jsdelivr.net; connect-src 'self' *.google-analytics.com; script-src 'self' *.googletagmanager.com; object-src 'self'; img-src 'self' data: https:; font-src 'self' https:; frame-src 'self' www.google.com www.youtube.com; manifest-src 'self'; base-uri 'self'; form-action 'self'; frame-ancestors 'self'; upgrade-insecure-requests;";

#add_header Feature-Policy "speaker self;fullscreen self;";
## Block common exploits
## https://www.howtoforge.com/nginx-how-to-block-exploits-sql-injections-file-injections-spam-user-agents-etc
Expand Down
16 changes: 16 additions & 0 deletions static/js/cookie-consent-listener.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
let gaInitialized = false;
document.addEventListener('cookieconsent_allowed', () => {
if (gaInitialized === true) return;
const script = document.createElement('script');
script.src = 'https://www.googletagmanager.com/gtag/js?id=G-TW89K2P8L4';
document.head.appendChild(script);
script.addEventListener('load', function () {
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-TW89K2P8L4');
gaInitialized = true;
});
});
50 changes: 25 additions & 25 deletions static/js/cookie-consent.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
const cookieConsent = (function () {
const
variable = 'cookieconsent_status',
allowedEvent = new CustomEvent('cookieconsent_allowed'),
allowStatus = 'allow',
denyStatus = 'deny',
const variable = 'cookieconsent_status';
const allowedEvent = new CustomEvent('cookieconsent_allowed');
const allowStatus = 'allow';
const denyStatus = 'deny';

removeModal = () => {
document.querySelector('.cookie-consent').remove();
},

allow = () => {
window.localStorage.setItem(variable, allowStatus);
document.dispatchEvent(allowedEvent);
removeModal();
},
const removeModal = () => {
document.querySelector('.cookie-consent').remove();
};
const allow = () => {
window.localStorage.setItem(variable, allowStatus);
document.dispatchEvent(allowedEvent);
removeModal();
};

deny = () => {
window.localStorage.setItem(variable, denyStatus);
removeModal();
},
const deny = () => {
window.localStorage.setItem(variable, denyStatus);
removeModal();
};

isAllowed = () => window.localStorage.getItem(variable) === allowStatus,
const isAllowed = () => window.localStorage.getItem(variable) === allowStatus;

isSet = () => window.localStorage.hasOwnProperty(variable),
const isSet = () => window.localStorage.hasOwnProperty(variable);

modalHTML = `
const modalHTML = `
<div class="cookie-consent">
<div class="cookie-consent-text">
We use cookies to analyze our traffic, so we can improve our website and give you a better experience.
View our <a target="_blank" href="https://northern.tech/legal/cookies">cookie policy</a>
</div>
<div class="cookie-consent-buttons">
<a class="btn btn-default" onclick="cookieConsent.deny()" href="javascript:void(0)">
<button class="btn btn-default" id="cookie-decline">
Decline
</a>
<a class="btn btn-primary" onclick="cookieConsent.allow()" href="javascript:void(0)">
</button>
<button class="btn btn-primary" id="cookie-allow">
Allow
</a>
</button>
</div>
</div>`;

Expand All @@ -49,6 +47,8 @@ const cookieConsent = (function () {
const wrapper = document.createElement("div");
wrapper.innerHTML = modalHTML;
document.body.appendChild(wrapper)
document.getElementById('cookie-decline').addEventListener('click', deny);
document.getElementById('cookie-allow').addEventListener('click', allow);
}


Expand Down
73 changes: 47 additions & 26 deletions static/js/main.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
document.querySelectorAll('[data-modal]').forEach(item => {
item.onclick = () => {
item.addEventListener('click', () => {
const modal = document.getElementById(item.dataset.modal);
modal.style.display = 'block';
modal.classList.remove('display-none');
modal.classList.add('display-block');
modal.querySelector('.btn-primary').focus();
const dc = item.closest('.dropdown-content');
if (dc) { // if element is part of dropdown then close dropdown
dc.classList.add('close');
setTimeout(() => dc.classList.remove('close'), 100);
}
}
})
})

window.onclick = e => {
if (e.target.classList.contains('modal')) {
e.target.style.display = "none";
window.addEventListener('click', (e)=>{
const {target} = e;
if (target.classList.contains('modal')) {
target.classList.remove('display-block');
target.classList.add('display-none');
}

if (!e.target.closest('.dropdown-select') || e.target.parentElement.classList.contains('dropdown-select_options')) {
if (!target.closest('.dropdown-select') || target.parentElement.classList.contains('dropdown-select_options')) {
document.querySelectorAll('.dropdown-select').forEach(item => item.classList.remove('opened'))
}
}
})

document.querySelectorAll('.dropdown-select span').forEach(item => item.onclick = () => {
document.querySelectorAll('.dropdown-select span').forEach(item => item.addEventListener('click', () => {
item.closest('.dropdown-select').classList.toggle('opened')
});
}));

const versionsDropdown = document.querySelector('.dropdown-select.versions');
if (versionsDropdown) {
Expand All @@ -35,44 +38,45 @@ if (versionsDropdown) {

document.onkeyup = e => {
if (e.key == 'Escape') {
document.querySelectorAll('.modal').forEach(item => item.style.display = 'none')
document.querySelectorAll('.modal').forEach(item => item.classList.add('display-none'))
}
}

const closeModal = (el) => el.closest('.modal').style.display = 'none';

const fakeLogin = (el) => {
el.style.display = 'none';
el.closest('li').querySelector('.logged').style.display = 'block';
}
// const fakeLogin = (el) => {
// el.style.display = 'none';
// el.closest('li').querySelector('.logged').style.display = 'block';
// }

document.querySelectorAll('.tabs div[data-tab]').forEach(item => {
item.onclick = function () {
item.addEventListener('click', () => {
document.querySelector('div[data-tab].active').classList.remove('active');
item.classList.add('active');
document.querySelector('.tabs-content.opened').classList.remove('opened');
document.getElementById(`tab${item.dataset.tab}`).classList.add('opened');
}
})
})


const collapse = document.querySelector('.collapse');

const dropDownHandler = function (element) {
const openedClass = "opened";
document.querySelector('li.dropdown.opened').classList.remove('opened');
const li = element.closest('li');
if (li.className.indexOf(openedClass) == -1) {
li.className += ` ${openedClass}`;
} else {
li.className = li.className.replace(` ${openedClass}`, "");
document.querySelectorAll('.dropdown-item-onclick.opened').forEach((el)=> el !== element && el.classList.toggle('opened') );

if(window.matchMedia("(pointer: coarse)").matches) {
element.classList.toggle('opened');
}
}
document.querySelectorAll('.dropdown-item-onclick').forEach(element=>{
element.addEventListener('click', (e)=>dropDownHandler(e.target));
})

const openMenuHandler = function (collapseMenu) {
const openMenuHandler = function () {
const collapseMenu = document.getElementById('openMenuToggle');
const menu = document.querySelector('.main-menu .links');

const openedClass = "opened";
document.querySelectorAll('.dropdown-item-onclick.opened').forEach((element)=>element.classList.toggle('opened'));
if (collapseMenu.className.indexOf(openedClass) == -1) {
collapseMenu.className += ` ${openedClass}`;
menu.className += ` d-b`;
Expand All @@ -81,6 +85,7 @@ const openMenuHandler = function (collapseMenu) {
menu.className = menu.className.replace(` d-b`, "");
}
}
document.getElementById('openMenuToggle').addEventListener('click', () => openMenuHandler());

const allTags = el => {
const tags = document.querySelector('.modules-right-tags_list');
Expand All @@ -92,6 +97,10 @@ const allTags = el => {
tags.classList.add('opened');
}
}
const allTagsElement = document.getElementById('all-tags');
allTagsElement?.addEventListener('click',(e)=>{
allTags(e.target);
})

let tm;
const cl = document.querySelector('.copy-link.bi-link-45deg');
Expand Down Expand Up @@ -126,3 +135,15 @@ String.prototype.capitalize = function() {
// remove all chars except alphanumeric, spaces and . , _ -
const sanitizeString = str => str !== null ? str.replace(/[^a-z0-9\.\s,_-]/gim,"") : null;

const publishModalElement = document.querySelector('[data-modal="publishModal"]');
publishModalElement.addEventListener('click', ()=>{
const closeModal = (el) => el.closest('.modal').classList.add('display-none');
document.querySelectorAll('.close-modal-click').forEach(element => {
element.addEventListener('click', e=> closeModal(e.target));
})
document.querySelectorAll('.opened').forEach(element=>element.classList.toggle('opened'))
const menu = document.querySelector('.links.d-b');
if (menu){
menu.classList.toggle('d-b');
}
})
Loading

0 comments on commit f881a64

Please sign in to comment.