Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add processes articles #8

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
77ab3b7
Add intro C articles
jackskennel May 31, 2022
7ab3d8f
add /articles/ page for navigation, including title metadata
wadefagen Jun 13, 2022
affedad
Merge branch 'main' of https://github.com/illinois/systems-encycloped…
wadefagen Jun 13, 2022
e088505
Initial commit of README.release.md
Jun 14, 2022
87714c8
Add bitwise ops and buffer overflow attack articles
jackskennel Jun 20, 2022
bf70a2f
Add architecture articles
jackskennel Jul 11, 2022
620e69a
Push new ISA article changes
jackskennel Jul 12, 2022
fcfe43e
WIP
wadefagen Jul 21, 2022
8031f3b
social preview work
wadefagen Jul 25, 2022
2551a30
Merge pull request #6 from illinois/waf-updates
wadefagen Jul 26, 2022
969a317
Add binary article
jackskennel Aug 23, 2022
9e82432
Add processes articles
jackskennel Aug 23, 2022
98b838b
Add virtual memory articles
jackskennel Aug 23, 2022
17079ca
Week 1 cleanup
jackskennel Aug 23, 2022
ba1c29e
Update intro-c.md
jackskennel Aug 23, 2022
f957913
mp0 release
wadefagen Aug 23, 2022
ceb6759
release link
wadefagen Aug 23, 2022
e38f09c
Merging release repository
wadefagen Aug 23, 2022
8ff0adc
Merge pull request #2 from illinois/c-articles
wadefagen Aug 25, 2022
04395bc
lec3
wadefagen Aug 30, 2022
d64dbbc
3 guides
wadefagen Sep 13, 2022
b4ab78f
added changes to make html display nicer on website, including resizi…
jshaffar Sep 16, 2022
8dbd00a
added title and author
jshaffar Sep 16, 2022
8bdac61
added title and author
jshaffar Sep 20, 2022
2b5299e
added title and fixed some grammatical mistakes
jshaffar Sep 20, 2022
25611ab
added title and name
jshaffar Sep 23, 2022
698ea53
KNO#1
wadefagen Oct 26, 2022
8589633
kno
wadefagen Oct 26, 2022
59c7ad5
Merge pull request #4 from illinois/architecture
wadefagen Nov 1, 2022
aab94ef
Merge pull request #7 from illinois/week1
wadefagen Nov 1, 2022
8575faf
Merge pull request #9 from illinois/vmem
wadefagen Nov 1, 2022
b39fe12
articles
wadefagen Nov 1, 2022
f006e17
removed mp0
jshaffar Nov 1, 2022
2f572b3
Merge pull request #12 from illinois/removed_mp0
jshaffar Nov 1, 2022
8da2666
sp23 update
wadefagen Jan 13, 2023
d3584e8
Merge branch 'main' of https://github.com/illinois/systems-encyclopedia
wadefagen Jan 13, 2023
0e5a097
Add processes articles
jackskennel Aug 23, 2022
9d30301
added title and name
jshaffar Sep 23, 2022
e695023
Some mistakes corrected
Feb 23, 2023
c18cea7
lde file modifed
Feb 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
187 changes: 186 additions & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const markdownIt = require("markdown-it")
const htmlmin = require("html-minifier")
const path = require('path')
const fs = require('fs')
const sharp = require("sharp");

const isProduction = process.env.NODE_ENV === 'production'
const slugify = require('slugify')
Expand Down Expand Up @@ -37,6 +38,7 @@ module.exports = function(eleventyConfig) {
'csv',
'html',
'css',
'gif',
// 'svg',
// 'liquid',
// 'pug',
Expand Down Expand Up @@ -85,5 +87,188 @@ module.exports = function(eleventyConfig) {
return `<pre class="code-output-block">${content}</pre>`;
});

return eleventyConfig

/* Preview Image Generator */
// https://github.com/manustays/eleventy-plugin-generate-social-images/blob/main/utils/generateSocialImage.js
function wrapTitle(title, rowLength = 23, maxRows = 3) {
let title_rows = [];
words = title.split(/(?<=[^a-zA-Z0-9()<>""''])/);
let _row = '';
words.forEach((wrd) => {
if (_row.length + wrd.length >= rowLength) {
title_rows.push(_row);
_row = '';
}
_row += wrd;
});
if (_row) {
title_rows.push(_row);
}

// Limit rows...
if (title_rows.length > maxRows) {
title_rows.length = maxRows;
title_rows[maxRows-1] += "…";
}

return title_rows;
}

function sanitizeHTML(text) {
return text.replace(/&/g, '&amp;')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&#039;');
}

function translateNetIDtoName(netid) {
switch (netid) {
case "waf": return "Prof. Wade Fagen-Ulmschneider";
case "kennel2": return "Jackson Kennel";
default:
console.warn(`Missing \`translateNetIDtoName\` in .eleventy.js for: ${netid}`);
return netid;
}
}

fs.mkdirSync("public/static/preview/", { recursive: true });
let authorImageCache = {};

eleventyConfig.addAsyncShortcode("GenerateSocialImage", async function () {
let {page, title, permalink, tags, isFuturePage, authors} = this.ctx;

if (!title || title.length == 0 || isFuturePage) {
return "";
}

// Check if it exists
let imageName = page.url.replace(/\//g, '_');
imageName = imageName.substring(1, imageName.length - 1) + '.png';
let localPath = `public/static/preview/${imageName}`;
let urlPath = `https://https://systems-encyclopedia.cs.illinois.edu/static/preview/${imageName}`;

if (fs.existsSync(localPath)) {
//return urlPath;
}


let start_x = 40;
let start_y = 200;
let line_height = 90;

// Create <text> elements for the post title:
let svg_title = "";
let title_rows = wrapTitle(title);
for (let i = 0; i < title_rows.length; i++) {
title_piece = sanitizeHTML(title_rows[i]);
svg_title += `<text x="${start_x}" y="${start_y + (i * line_height)}" fill="#DD3403" font-size="80px" font-weight="700">${title_piece}</text>`;
}

start_y += (title_rows.length * line_height) - 10;


if (!authors) {
authors = ["waf"];
}

let svg_by = "";
let author_images = [];

if (authors.length > 0) {
}

for (let i = 0; i < authors.length; i++) {
let author = authors[i];

if (i == 0) {
svg_by += `<text x="${start_x}" y="${start_y}" fill="#13294B" font-size="50px" font-weight="700">w/</text>`;
} else {
svg_by += `<text x="${start_x + 30}" y="${start_y}" fill="#aaa" font-size="50px" font-weight="700">+</text>`;
}

svg_by += `<circle cx="${start_x + 70 + 25}" cy="${start_y - 45 + 25}" r="27" fill="#13294B" />`;
svg_by += `<text x="${start_x + 130}" y="${start_y}" fill="#13294B" font-size="50px" font-weight="700">${translateNetIDtoName(author)}</text>`;

author_images.push({ x: start_x + 70, y: start_y - 45, author: author });
start_y += 60;

if (i == 0) {
start_x += 40;
}
}


/*
let svg_category = "";
if (!tags) {
// No text
} else if (tags.includes("guides")) {
svg_category += `<text x="50" y="155" fill="white" font-size="70px" font-weight="700">Data Science Guide</text>`;
} else if (tags.includes("learn")) {
svg_category += `<text x="50" y="155" fill="white" font-size="70px" font-weight="700">Lecture Notes</text>`;
} else if (tags.includes("dataset")) {
svg_category += `<text x="50" y="155" fill="white" font-size="70px" font-weight="700">Dataset</text>`;
}
*/



// Create the SVG:
let svg = `
<svg width="1200" height="630" viewbox="0 0 1200 630" xmlns="http://www.w3.org/2000/svg">
<g style="font-family: Archivo;">
${svg_title}
${svg_by}
</g>
</svg>`;

// Save the image:
const svgBuffer = Buffer.from(svg);

const svgText = await sharp(svgBuffer)
.resize(1200, 630)
.toBuffer();


let composite_author_images = [];
for (let author_image of author_images) {
if (!authorImageCache[author_image.author]) {
let authorPhotoPath = `src/static/staff/${author_image.author}.jpg`;

let author50px;
if (fs.existsSync(authorPhotoPath)) {
author50px = await sharp(`src/static/staff/${author_image.author}.jpg`)
.resize({ width: 50, height: 50, fit: "contain" })
.toBuffer();
} else {
author50px = await sharp(`src/static/staff/missing.svg`)
.resize({ width: 50, height: 50, fit: "contain" })
.toBuffer();
}

authorImageCache[author_image.author] = await sharp(Buffer.from(`<svg height="50" width="50"><circle cx="25" cy="25" r="25" fill="white"/></svg>`))
.composite([{ input: author50px, blend: "in" }])
.toBuffer();
}

composite_author_images.push({
input: authorImageCache[author_image.author],
left: author_image.x,
top: author_image.y,
})
}

const background = await sharp("preview-template.png")
.composite([
{ input: svgText, top: 0, left: 0 },
...composite_author_images
])
.png()
.toFile(localPath);

return urlPath;
})

return eleventyConfig;
}
35 changes: 35 additions & 0 deletions .github/workflows/gen-status-report.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
echo "## Workflow summary :rocket:"

case "$sr_checkout_status" in
("success") echo "### ✅ Succesfully checked out student repository\n";;
("failure") echo "### ❌ Error checking out student repository" &&
echo "If you see this message, please contact course staff so we can resolve the issue.\n";;
esac

case "$release_checkout_status" in
("success") echo "### ✅ Succesfully checked out release repository\n";;
("failure") echo "### ❌ Error checking out release repository" &&
echo "If you see this message, please contact course staff so we can resolve the issue.\n";;
("skipped") echo "### ⬜ Skipped checking out release repository\n";;
esac

case "$local_copy_status" in
("success") echo "### ✅ Succesfully copied files from release\n";;
("failure") echo "### ❌ Error copying files from release" &&
echo "If you see this message, please contact course staff so we can resolve the issue.\n";;
("skipped") echo "### ⬜ Skipped copying files from release\n";;
esac

case "$verify_policy_status" in
("success") echo "### ✅ Succesfully verified student submission\n";;
("failure") echo "### ❌ Student submission not successfully verified" &&
echo "If you see this message, it is likely because you submitted this assignment for grading after the due date." &&
echo "If you are absolutely sure you have submitted this assignment on time, please contact course staff.\n";;
("skipped") echo "### ⬜ Skipped verifying student submission\n";;
esac

case "$autograding_status" in
("success") echo "### ✅ Student submission passed autograding! 🎉";;
("failure") echo "### ❌ Student submission did not pass autograding";;
("skipped") echo "### ⬜ Skipped autograding";;
esac
48 changes: 48 additions & 0 deletions .github/workflows/mp0-autograder-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: mp0 autograding
'on':
workflow_dispatch: {}
jobs:
autograding:
name: autograding
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout release repository
id: sr-checkout
uses: actions/checkout@v2
- name: Checkout release repository
id: release-checkout
uses: actions/checkout@v2
with:
repository: cs340-illinois/fa22_cs340_.release
ref: mp0
path: release
- name: Copy local files from release
id: local-copy
uses: illinois/local-copy@v1
with:
src_path: release/mp0
dst_path: mp0
copy: '.github/classroom : .github/classroom, Makefile : Makefile, tests : tests'
- name: Verify student submission
id: verify-policy
uses: illinois/verify-policy@v1
with:
reference_files: 'release/mp0/.github/classroom : mp0/.github/classroom, release/mp0/Makefile : mp0/Makefile, release/mp0/tests : mp0/tests'
- name: Autograding
id: autograding
uses: wadefagen/autograding@v2
with:
path: mp0/
test_suite: autograding
step_summary: true
- name: Generate workflow summary
if: ${{ always() }}
run: echo -e "$(sh ./.github/scripts/gen-status-report.sh)" >> $GITHUB_STEP_SUMMARY
env:
sr_checkout_status: ${{ steps.sr-checkout.outcome }}
release_checkout_status: ${{ steps.release-checkout.outcome }}
local_copy_status: ${{ steps.local-copy.outcome }}
verify_policy_status: ${{ steps.verify-policy.outcome }}
autograding_status: ${{ steps.autograding.outcome }}
points: ${{ steps.autograding.outputs.Points }}
7 changes: 7 additions & 0 deletions README.release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CS 340 (fa22)

This file was created automatically as a placeholder in the shared `.release` repo for the course.

For next steps, please refer to the instructions provided by your course.

**Note:** In order to avoid unnecessary merge conflicts with student repos, this file has been intentionally named `README.release.md` instead of `README.md`. We recommend that staff not rename this file.
5 changes: 5 additions & 0 deletions fonts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<dir prefix="default">fonts</dir>
</fontconfig>
Binary file added fonts/Archivo-Italic-VariableFont_wdth,wght.ttf
Binary file not shown.
Binary file added fonts/Archivo-VariableFont_wdth,wght.ttf
Binary file not shown.
Loading