Skip to content

Commit

Permalink
Test readme iframe
Browse files Browse the repository at this point in the history
  • Loading branch information
JuhoErvasti committed Nov 7, 2023
1 parent 034a417 commit fd6ccc3
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 39 deletions.
30 changes: 0 additions & 30 deletions .github/workflows/update-tokens.yaml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/update-tokens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# name: Extract tokens

# on:
# push:
# paths:
# - 'harjoitukset/build/*.html'

# jobs:
# extract-tokens:
# runs-on: ubuntu-latest

# steps:
# - name: Checkout Repository
# uses: actions/checkout@v2

# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# python-version: 14

# - name: Extract Answer Token
# run: ./replace_tokens.sh
9 changes: 1 addition & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,7 @@ Materiaaleja voi muokata joko käyttäen RStudiota, jolloin päivityksiä on hel

### Ratkaisuavaimet

```
HARJOITUS 3: slprt13
HARJOITUS 4: ailse11
HARJOITUS 5: kteoh45
HARJOITUS 6: aierl12
HARJOITUS 7: atjes2
HARJOITUS 8: onihd24
```
<iframe src="tokens.html"></iframe>

## Lisenssit
Harjoitusmateriaalit on julkaistu avoimella lisenssillä. Käytettävä lisenssi on [Creative Commons Nimeä-EiMuutoksia 4.0](https://creativecommons.org/licenses/by-nd/4.0/deed.fi).
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion harjoitukset/build/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
<meta property="og:type" content="book" />



<button onclick="toggleAnswer(this)" class="btn answer_btn token">
ratkaisu
</button>


<meta name="author" content="Gispo Oy" />
Expand Down
25 changes: 25 additions & 0 deletions replace_tokens.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

html_file="tokens.html"

declare -A tokens

#for file in $(find harjoitukset/build -name "*.html"); do
for file in $(find harjoitukset/build -name "*.html" | sort); do
if grep -q -E '<button[^>]*class="[^"]*token[^"]*"' "$file"; then
title=$(grep -m 1 "<title>.*<\/title>" "$file" | sed -E 's/<\/?title>//g')
answerToken=$(node extract-token.js "$title")

file_name=$(basename "$file")
exercise_number=${file_name%.html}
exercise_number=${exercise_number##*_}
tokens["HARJOITUS $exercise_number"]=$answerToken
fi
done

> "$html_file"

for key in "${!tokens[@]}"; do
value="${tokens[$key]}"
echo "<p>$key: $value</p>" >> "$html_file"
done
7 changes: 7 additions & 0 deletions tokens.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<p>HARJOITUS 4: </p>
<p>HARJOITUS 5: </p>
<p>HARJOITUS 6: </p>
<p>HARJOITUS 7: </p>
<p>HARJOITUS 3: </p>
<p>HARJOITUS 8: </p>
<p>HARJOITUS index: </p>

0 comments on commit fd6ccc3

Please sign in to comment.