Compare commits

..

21 commits

Author SHA1 Message Date
d739b4cfe8
feat: add humans.txt (#30) 2023-06-05 15:19:18 +02:00
6cde286d3b
feat: add gtag.js 2022-11-08 19:11:33 +01:00
Victor Westerlund
7ce5ceea9e fix: supports backdrop-filter 2022-02-28 03:27:46 -08:00
Victor Westerlund
750ae4a6cb fix(nit): error page urls 2022-02-23 23:21:45 +01:00
Victor Westerlund
83d8ca71c1 Merge branch 'master' of github.com:VictorWesterlund/victorwesterlund.com 2022-02-22 15:22:50 +01:00
Victor Westerlund
062f324783 fix(nit): og:url tag 2022-02-22 15:22:38 +01:00
597b13c01a
template(lighthouse): add "device" column 2022-02-22 06:07:22 -08:00
be42bc7cbb
Update LICENSE 2022-02-22 05:32:55 -08:00
5c3569eed8
Update README.md 2022-02-22 05:25:15 -08:00
36345199e3
Version 11 (#23)
* wip(22w6a): add glitch bg

* wip(22w6b): add content and more glitching

* wip(22w7a): add card backdrop-filter

* wip(22w7b): add visibilitychange event

* wip(22w7c): add link click handler

* wip(22w7d): add webkit backdrop filter support

* wip(22w7e): fix font size

* wip(22w7f): refactor glitch

* wip(22w7g): add forceBg to glitch

* wip(22w7h): add error page

* wip(22w7i): hide contact button

* feat: add OGP tags

Co-authored-by: Cloud Shell <cloud-shell@victor-westerlund.iam.gserviceaccount.com>
2022-02-22 04:46:05 -08:00
1dd61b7596
Create codeql-analysis.yml 2022-02-20 07:31:07 -08:00
64db7544b7 Move api.php to /src 2021-12-29 16:29:17 +01:00
cb6a0e9ec5 Fix error page asset links 2021-12-28 20:40:18 +01:00
a63714304b Add style for search input clear
Styling overrides for the clear button present in some browsers for input="search"
2021-12-28 20:27:05 +01:00
1f0024afa6 Merge branch 'master' of https://github.com/VictorWesterlund/victorwesterlund.com 2021-12-28 18:22:01 +01:00
52a7961f36 Add GH issue template Lighthouse 2021-12-28 18:21:52 +01:00
Victor Westerlund
9413b2ac4e
Fix error page link 2021-12-28 01:11:09 +01:00
0cd5d11cd8 Squashed commit of the following:
commit 17b429555fceefc9c3500ddee4da8c6902d9674a
Author: Victor Westerlund <victor.vesterlund@gmail.com>
Date:   Tue Dec 28 01:00:11 2021 +0100

    Optimize assets and pages

commit c05e4bb5eabd9ef2b96eccb347cc0399cb6869f8
Author: Victor Westerlund <victor@victorwesterlund.com>
Date:   Tue Dec 14 18:06:52 2021 +0100

    Add noopener link type

    Prevents Spotify from accessing the window object of victorwesterlund.com.
    I think sending the referrer header is fine so noreferrer is not needed

commit cc3cca09ac02cc0bf45204bbe52dcc20ee10a2eb
Author: Victor Westerlund <victor.vesterlund@gmail.com>
Date:   Sun Dec 12 15:56:05 2021 +0100

    Add desktop style

    Added the desktop overrides as media queries for a mobile-first approach. Also added the "more" and "contact" pages.

commit de6f30a7c2525e5bb7a31a55f11a40fc33347f85
Author: Victor Westerlund <victor.vesterlund@gmail.com>
Date:   Sun Dec 12 14:46:21 2021 +0100

    New content and CSS refactor

    Content template for "more" and major CSS refactor
2021-12-28 01:01:26 +01:00
9526e7bf52 Core functions compartmentalized 2021-12-01 17:07:47 +01:00
Victor Westerlund
b08169fe88
Remove CSS property
Turns out it wasn't needed after all
2021-11-04 23:12:08 +01:00
Victor Westerlund
24b35e36fd
Fix CSS property typo 2021-11-04 12:54:26 +01:00
48 changed files with 901 additions and 763 deletions

13
.github/ISSUE_TEMPLATE/lighthouse.md vendored Executable file
View file

@ -0,0 +1,13 @@
---
name: Lighthouse
about: Audit non-conformity (issue or fix)
title: "[Category]"
labels: lighthouse
assignees: ''
---
> Replace with description
Device|Category|Score before fix|Score after fix
--|--|--|--

0
.gitignore vendored Normal file → Executable file
View file

355
LICENSE Normal file → Executable file
View file

@ -1,24 +1,339 @@
This is free and unencumbered software released into the public domain.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
Preamble
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
For more information, please refer to <https://unlicense.org>
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

81
README.md Normal file → Executable file
View file

@ -1,46 +1,41 @@
<div align="center">
<img width="100px" src="https://storage.googleapis.com/public.victorwesterlund.com/github/VictorWesterlund/victorwesterlund.com/vw.svg"/>
<h3><strong><code>www.victorwesterlund.com</code></strong></h3>
<p>The source code for <a href="https://victorwesterlund.com">victorwesterlund.com</a></p>
<h3>Source code for <a href="https://victorwesterlund.com"><strong>victorwesterlund.com</strong></a></h3>
</div>
<h1 align="center">How to install</h1>
<p>This guide is for Unix-based systems with NGINX, PHP 8.0 and MariaDB installed and configured.</p>
<ol>
<li><strong>Clone this repo.</strong><br><pre>git clone https://github.com/VictorWesterlund/victorwesterlund.com /var/www</pre></li>
<li><strong>Expose the directory <code>/public</code> to the web.</strong><br>This can be done in multiple ways, but an <a href="http://nginx.org/en/docs/http/ngx_http_core_module.html#location">NGINX <code>location</code> block</a> or symlink should do the trick.</li>
<li><strong>Rewrite <code>api.php</code> to <code>api/*</code>.</strong><br>All requests to <code>example.com/api/*</code> should be routed to the PHP file at <code>/public/api.php</code>.<br>Just like the previous step, this can be done in multiple ways. Here is one way with an NGINX location block:<br>
<pre>location ~ /api/* {
try_files /public/api.php =503;
include snippets/fastcgi-php.local.conf;
fastcgi_pass unix:/run/php/php8.0-fpm.sock;
}</pre></li>
<li><strong>Add support for the <code>.mjs</code> extension.</strong><br>NGINX doesn't have an entry for the <a href="https://jakearchibald.com/2017/es-modules-in-browsers/#mime-types">ECMAScript module <i>(<code>.mjs</code>)</i></a> file extension in its default <code>/etc/nginx/mime.types</code> file. We need to add this manually:<br>
<pre>
types {
...
application/javascript js mjs;
...
}
</pre><i>PS: If you want to make your <code>Content-Type</code> <a href="https://html.spec.whatwg.org/multipage/scripting.html#scriptingLanguages">WG compliant</a>, replace <code>application/javascript</code> with <code>text/javascript</code></i></li>
<li><strong>Import the standard structure to a MariaDB database.</strong><br>A MySQL-compatible <code>.sql</code> can be <a href="https://example.com">downloaded here</a> and imported into a database with this command:<br><pre>mysql -u username -p database_name < db_structure.sql</pre>You will have to create an empty database if you don't have one already.</li>
<li><strong>Add your MariaDB connection details to <code>/src/database/config.json</code>.</strong><br>You can add as many fallback servers as you want
<pre lang="json">
{
"servers": [
{
"host": "db.example.com",
"user": "mysql_user",
"pass": "mysql_pass",
"db": "mysql_db"
},
{
"host": "fallback.db.example.com",
"user": "mysql_user",
"pass": "mysql_pass",
"db": "mysql_db"
}
]
}
</pre></li>
</ol>
<p>That was a lot, but now we're done! Navigate to the location you exposed in step 2 and cross your fingers 🤞</p>
## Local installation
If someone for whatever reason want to set up their own environment of this. Here's how you do so assuming you have [NGINX](https://nginx.org/en/) up and running:
1. **Clone this repo**
```
git clone https://github.com/VictorWesterlund/victorwesterlund.com
```
2. **Create an NGINX site config**
Create and enable a new site + server config with the `root` pointed to the **/public** folder inside the repo.
3. **Add support for `.mjs`**
I'm using the hyped .mjs extension for the ES modules and NGINX does not serve the correct MIME-type for these yet.
Open **/etc/nginx/mime.types** with your text editor of choice and add `mjs` to the `application/javascript` MIME-type. Save and exit.
```
types {
...
application/javascript js mjs;
...
}
```
*Psst: if you shiver at the sight of JS using another type than your HTML:s and CSS:ess (you are my kind of nerd), replace **application/javascript** with **text/javascript** and remain [WHATWG compliant](https://mimesniff.spec.whatwg.org/#javascript-mime-type)😚*
4. **Fire up NGINX with the new config**
Verify that your changes are valid and restart NGINX. Hop over to your browser and navigate to your set endpoint - fingers crossed 🤞
```
nginx -t
sudo systemctl restart nginx
```

70
codeql-analysis.yml Normal file
View file

@ -0,0 +1,70 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ master ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ master ]
schedule:
- cron: '44 17 * * 3'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://git.io/codeql-language-support
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View file

@ -1,52 +0,0 @@
<?php
require_once dirname(__DIR__,1)."/src/Globals.php";
class APIRouter {
public function __construct($path) {
// List of implemented API services
$this->services = [
"search" => function() {
require_once dirname(__DIR__,1)."/src/search/Search.php";
new Search();
}
];
$this->url = parse_url($path);
$this->run();
}
// Find the requested service by looking at the next URI breadcrumb after "api"
private function get_service() {
$path = explode("/",$this->url["path"]);
$service = array_search("api",$path) + 1; // Next array value
$service = $path[$service];
return $service;
}
private function error($message,$code = 500) {
$output = [
"ok" => false,
"code" => strval($code),
"message" => $message
];
header("Content-Type: application/json");
http_response_code($code);
echo json_encode($output);
}
// Run the requested service if it exists in services list
private function run() {
$service = $this->get_service();
if(!array_key_exists($service,$this->services)) {
$this->error("Inavlid API");
return false;
}
// Import and run requested service
$this->services[$service]();
}
}
new APIRouter($_SERVER["REQUEST_URI"]);

View file

@ -1,31 +0,0 @@
/* Victor Westerlund - www.victorwesterlund.com */
a {
font-weight: bold;
}
a::after {
content: " →";
}
main {
display: flex;
flex-direction: column;
gap: 30px;
font-size: 20px;
transform: translateY(0);
}
/* -- Media Queries -- */
@media (max-width: 300px) {
main {
text-align: center;
align-items: center;
}
}
@media print {
a::after {
content: ": " attr(href);
}
}

View file

@ -1,241 +0,0 @@
/* Victor Westerlund - www.victorwesterlund.com */
:root {
--padding: 20px;
--max-width: 800px;
}
html,
body {
justify-content: flex-start;
}
header {
display: flex;
align-items: center;
height: 100px;
min-height: 80px;
flex: none;
}
header h1 {
font-size: clamp(16px,5vw,25px);
font-weight: normal;
}
/* -- Searchbox -- */
#search input {
background-color: var(--swatch-contrast);
color: var(--swatch-background);
border: none;
font-size: 16px;
width: calc(100vw - (var(--padding) * 2));
max-width: var(--max-width);
text-transform: lowercase;
padding: var(--padding);
}
#search input::placeholder {
color: rgba(var(--palette-background),.4);
}
#search input::selection {
color: var(--swatch-contrast);
background-color: var(--swatch-background);
}
#search input:focus {
outline: none;
}
/* -- Results -- */
#results {
width: calc(var(--max-width) + (var(--padding) * 4));
max-width: 100%;
box-sizing: border-box;
padding: var(--padding);
display: flex;
flex-direction: column;
overflow-y: auto;
gap: var(--padding);
}
#results > p {
text-align: center;
}
#results > p.error {
color: red;
}
#results > p.error::before {
content: "😰 ";
}
.card {
--padding-multiplier: 1.2;
flex: none;
display: flex;
flex-direction: column;
gap: calc(var(--padding) * var(--padding-multiplier));
padding: calc(var(--padding) * var(--padding-multiplier));
box-sizing: border-box;
width: 100%;
overflow: auto;
border: solid 1px var(--swatch-contrast);
}
.card > div {
--icon-size: 40px;
display: grid;
grid-template-columns: var(--icon-size) 1fr;
align-items: center;
font-weight: bold;
gap: calc(var(--padding) * var(--padding-multiplier));
}
.card > div *:not(p) {
width: var(--icon-size);
}
.card > div p {
font-size: clamp(16px,1vw,20px);
word-break: break-word;
}
/* -- Results > Types -- */
.card.error {
gap: unset;
}
.card.error p > a {
background-color: rgba(var(--palette-contrast),.1);
}
.resultsFooter {
display: flex;
justify-content: space-between;
align-items: center;
}
.resultsFooter p {
text-align: center;
padding: 0 var(--padding);
}
.resultsFooter p span:last-child {
display: none;
}
.resultsFooter svg {
width: 41px;
height: 40px;
flex: none;
}
.resultsFooter svg polygon {
fill: none;
stroke: rgba(var(--palette-contrast),.1);
stroke-width: 1px;
}
.resultsFooter svg.active polygon {
fill: var(--swatch-contrast);
stroke: var(--swatch-contrast);
}
/* ---- */
.button {
padding: var(--padding);
text-align: center;
background-color: var(--swatch-contrast);
color: var(--swatch-background);
box-shadow: inset 0 0 0 2px var(--swatch-contrast);
user-select: none;
}
/* -- Media Queries -- */
@media (max-width: 300px) {
.card > div {
grid-template-columns: 1fr;
}
.card > div *:not(p) {
display: none;
}
}
@media (min-width: 600px) {
.resultsFooter p span:last-child {
display: initial;
}
}
@media (hover: hover) {
.button:hover {
background-color: rgba(var(--palette-contrast),0);
color: var(--swatch-contrast);
cursor: pointer;
}
.button:active {
background-color: rgba(var(--palette-contrast),.1);
color: var(--swatch-contrast);
cursor: pointer;
}
/* ---- */
.resultsFooter svg.active:hover polygon {
fill: var(--swatch-background);
cursor: pointer;
}
.resultsFooter svg.active:active polygon {
fill: rgba(var(--palette-contrast),.1);
}
}
@media (pointer: fine) {
#search input:focus {
outline: solid 5px rgba(var(--palette-contrast),.2);
}
/* ---- */
#results::-webkit-scrollbar {
width: 10px;
}
#results::-webkit-scrollbar-track {
background-color: rgba(var(--palette-contrast),.04);
}
#results::-webkit-scrollbar-thumb {
background: var(--swatch-contrast);
}
#results::-webkit-scrollbar-thumb:hover {
background: var(--swatch-background);
outline: solid 2px rgba(var(--palette-contrast),1);
}
#results::-webkit-scrollbar-thumb:active {
background: rgba(var(--palette-contrast),.1);
outline: solid 2px rgba(var(--palette-contrast),1);
}
}
@media (prefers-color-scheme: dark) {
#search {
--palette-background: 255,255,255;
--palette-contrast: 33,33,33;
--swatch-background: rgb(var(--palette-background));
--swatch-contrast: rgb(var(--palette-contrast));
}
}

217
public/assets/css/style.css Normal file → Executable file
View file

@ -1,74 +1,205 @@
/* Victor Westerlund - www.victorwesterlund.com */
:root {
--palette-background: 255,255,255;
--palette-contrast: 33,33,33;
--color-base: 0, 0, 0;
--color-contrast: 256, 256, 256;
--swatch-background: rgb(var(--palette-background));
--swatch-contrast: rgb(var(--palette-contrast));
}
@font-face {
font-family: "Roboto Mono";
font-weight: normal;
font-style: normal;
src: local("Roboto Mono Regular"), local("RobotoMono-Regular"),
url("../fonts/RobotoMono-Regular.woff2") format("woff2"),
url("../fonts/RobotoMono-Regular.woff") format("woff");
}
@font-face {
font-family: "Roboto Mono";
font-weight: bold;
font-style: normal;
src: local("Roboto Mono Bold"), local("RobotoMono-Bold"),
url("../fonts/RobotoMono-Bold.woff2") format("woff2"),
url("../fonts/RobotoMono-Bold.woff") format("woff");
--padding: clamp(40px, 2vw, 2vw);
--border-size: clamp(4px, .25vw, .25vw);
}
/* -- Cornerstones -- */
* {
margin: 0;
font-family: "Roboto Mono","Arial",sans-serif;
color: var(--swatch-contrast);
font-family: "Monaco", "Consolas", monospace, sans-serif;
color: rgb(var(--color-contrast));
}
*::selection {
background-color: var(--swatch-contrast);
color: var(--swatch-background);
background-color: rgb(var(--color-contrast));
color: rgb(var(--color-base));
}
html,
body {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
width: 100%;
height: 100%;
overflow: hidden;
background-color: var(--swatch-background);
overflow-x: hidden;
}
a {
display: content;
html {
background-color: rgba(var(--color-base), .7);
background-size: cover;
background-blend-mode: overlay;
background-position: center;
background-attachment: fixed;
}
picture {
display: contents;
}
h1 {
font-size: clamp(45px, 7vw, 6vh);
}
p, a {
font-size: clamp(20px, 3vw, 2vh);
text-align: justify;
}
/* -- Components -- */
body {
display: flex;
flex-direction: column;
align-items: center;
justify-items: center;
gap: var(--padding, 30px);
}
body > div {
padding: calc(var(--padding) / 2);
}
:is(#intro, #card) a {
--padding-vert: clamp(17px, 1.1vw, 1.1vw);
display: inline-block;
text-decoration: none;
text-align: center;
user-select: none;
background-color: rgba(var(--color-contrast), .13);
backdrop-filter: blur(2px);
-webkit-backdrop-filter: blur(2px);
box-shadow:
inset 0 .3vh 1.6vh rgba(0, 0, 0, 0),
0 .1vh .3vh rgba(0, 0, 0, .12),
0 .1vh .2vh rgba(0, 0, 0, .24);
}
/* --- */
#intro {
padding: calc(var(--padding) / 2);
}
#intro a {
padding: var(--padding-vert) 2vw;
border-radius: 100px;
border: solid var(--border-size) rgba(var(--color-contrast), 0);
margin: var(--padding) 0;
width: calc(100% - ((var(--padding) / 2) + var(--border-size)));
}
#intro p {
margin: 1vh 0;
font-size: clamp(20px, 3vw, 3vh);
}
/* --- */
#card,
#card > div {
display: flex;
flex-direction: column;
align-items: center;
gap: calc(var(--padding) / 2);
}
#card {
--portrait-size: clamp(128px, 12vw, 12vh);
position: relative;
max-width: 600px;
padding: var(--padding);
border-radius: clamp(18px, 1vw, 1vw);
backdrop-filter: saturate(100) brightness(.4);
-webkit-backdrop-filter: saturate(100) brightness(.4);
border: solid var(--border-size) rgba(var(--color-contrast), .1);
box-shadow: 0 1vh 2vh rgba(0, 0, 0, .19), 0 6px 6px rgba(0, 0, 0, .23);
}
#card img {
width: var(--portrait-size);
height: var(--portrait-size);
position: absolute;
border-radius: 100%;
top: calc(((var(--portrait-size) / 2) + var(--border-size)) * -1);
background-color: rgb(var(--color-base));
box-shadow: 0 1vh 2vh rgba(0, 0, 0 , .19), 0 6px 6px rgba(0, 0, 0 , .23);
}
#card a {
width: 100%;
padding: var(--padding-vert) 0;
margin-top: calc(var(--padding) / 2);
border-radius: clamp(9px, .5vw, .5vw);
}
/* -- Media Queries -- */
@supports ((not ((backdrop-filter: saturate(1)) and (backdrop-filter: brightness(1)))) and (not ((-webkit-backdrop-filter: saturate(1)) and (-webkit-backdrop-filter: brightness(1))))) {
#card {
background-color: rgba(var(--color-base), .7);
}
}
@media (pointer: fine) {
a:hover {
background: rgba(var(--palette-contrast),.1);
:is(#intro, #card) a {
--transition-speed: 200ms;
transition:
var(--transition-speed) background-color,
var(--transition-speed) box-shadow,
var(--transition-speed) border-color;
}
:is(#intro, #card) a:hover {
background-color: rgba(var(--color-contrast), .2);
border-color: rgba(var(--color-contrast), .2);
box-shadow:
inset 0 .3vh 1.6vh rgba(0, 0, 0, .16),
0 .3vh .6vh rgba(0, 0, 0, .16),
0 .3vh .6vh rgba(0, 0, 0, .23);
}
:is(#intro, #card) a:active {
background-color: rgba(var(--color-contrast), .15);
}
}
@media (prefers-color-scheme: dark) {
:root {
--palette-background: 0,0,0;
--palette-contrast: 255,255,255;
@media (max-width: 330px) {
p, a {
text-align: left;
font-size: 18px;
}
--swatch-background: rgb(var(--palette-background));
--swatch-contrast: rgb(var(--palette-contrast));
#card {
padding: calc(var(--padding) / 2);
}
}
@media (min-aspect-ratio: 14/9) and (min-height: 600px) {
body {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: unset;
}
body > div {
display: grid;
align-items: center;
}
body > div:last-of-type {
padding: calc(var(--padding) * 2);
}
#intro a {
width: unset;
}
#card {
min-width: 300px;
max-width: 30vw;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,79 @@
// Fetch and create glitchy background effects
class Generator {
constructor() {
this.bg = {
_this: this,
_image: null,
_dir: location,
_dir_rel: "assets/media/b64/",
count: 4,
// Get or set current background
get current () { return this._image; },
set current (image) {
this._image = image;
this._this.setBg(image);
},
// Get or set the path to where base64 images are stored
get dir () { return this._dir; },
set dir (newPath) {
const url = new URL(newPath);
// Replace pathname of this file with relative path to assets
const path = url.pathname.split("/");
path[path.length - 1] = this._dir_rel;
url.pathname = path.join("/");
this._dir = url.toString();
}
}
}
// Genrate random int in range
static randInt(min, max) {
if(min === max) return min;
return Math.round(Math.random() * (max - min) + min);
}
// Generate random string of length from charset
static randStr(length = 2) {
const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
let output = "";
for(let i = 0; i < length; i++) {
output += charset.charAt(Math.floor(Math.random() * charset.length));
}
return output;
}
// Give generated background image to parent thread
setBg(image) {
if(typeof image !== "string") throw new TypeError("Image must be of type 'string'");
postMessage(["BG_UPDATE", image]);
}
// Generate and set a glitchy image
glitch() {
if(!this.bg.current) return;
const image = this.bg.current.replaceAll(Generator.randStr(), Generator.randStr());
this.setBg(image);
}
// Fetch a base64 encoded background image
async fetchBg(id) {
const url = new URL(this.bg.dir);
url.pathname += id + ".txt";
const image = await fetch(url);
if(!image.ok) throw new Error("Failed to fetch background image");
return image.text();
}
// Load a random background from the image set
async randBg() {
const id = Generator.randInt(1, this.bg.count);
const image = await this.fetchBg(id);
this.bg.current = image;
}
}

View file

@ -0,0 +1,41 @@
export default class Glitch {
constructor(target) {
this.worker = new Worker(this.getWorkerScriptURL());
this.worker.addEventListener("message", event => this.message(event));
this.target = target ? target : document.body;
}
// Update the target CSS background with an image URL
setVisibleBg(image) {
this.target.style.setProperty("background-image", `url(${image})`);
}
// Get URL for the dedicated worker
getWorkerScriptURL() {
const name = "GlitchWorker.js";
const url = new URL(import.meta.url);
// Replace pathname of this file with worker
const path = url.pathname.split("/");
path[path.length - 1] = name;
url.pathname = path.join("/");
return url.toString();
}
// Event handler for messages from worker thread
message(event) {
const data = typeof event.data === "object" ? event.data : [event.data];
switch(data[0]) {
case "READY":
this.worker.postMessage(["START", new URL(location).toString()]);
break;
case "BG_UPDATE":
this.setVisibleBg(data[1]);
break;
}
}
}

View file

@ -0,0 +1,54 @@
importScripts("./Generator.mjs");
class GlitchWorker extends Generator {
constructor() {
super();
// Delay between these values
this.config = {
glitch: { min: 500, max: 2500 },
randBg: { min: 5000, max: 5000 }
}
this._timers = {};
self.addEventListener("message", event => this.message(event));
self.postMessage("READY");
}
// Run a scoped function on a random interval between
queue(func) {
clearTimeout(this._timers[func]);
const next = Generator.randInt(this.config[func].min, this.config[func].max);
this._timers[func] = setTimeout(() => this.queue(func), next);
this[func]?.();
}
// Set background by id and stop randBg animation
async forceBg(id) {
clearTimeout(this._timers.randBg);
const image = await this.fetchBg(id);
this.bg.current = image;
this.setBg(image);
}
// Event handler for messages from parent thread
message(event) {
const data = typeof event.data === "object" ? event.data : [event.data];
switch(data[0]) {
case "START":
this.bg.dir = data[1];
this.randBg();
for(const func of Object.keys(this.config)) {
this.queue(func);
}
break;
}
}
}
self.glitch = new GlitchWorker();

View file

@ -1,96 +0,0 @@
export default class Search {
constructor(input,results) {
const self = this;
this.endpoint = new URL("api/search",window.location.href);
this.lastQuery = "";
this.throttle = null;
this.controller = null; // AbortController will be assigned here
this.results = results;
this.input = input;
this.input?.addEventListener("keyup",event => this.keyEvent(event)) ?? false;
}
// Destroy the result DOM tree
clearResults() {
while(this.results.firstChild) {
this.results.removeChild(this.results.lastChild);
}
}
// Display output as HTML
output(html) {
this.clearResults();
if(typeof html === "string") {
this.results.insertAdjacentHTML("beforeEnd",html);
return;
}
this.results.appendChild(html);
}
// Display a status message in a paragraph
status(text,classList = false) {
const element = document.createElement("p");
if(classList !== false) {
element.classList = classList;
}
element.innerText = text;
this.output(element);
}
// Fetch search results from endpoint
async search(query) {
const url = new URL(this.endpoint);
url.searchParams.set("q",query);
const timeout = new Promise(reject => setTimeout(() => reject("Request timed out"),3000));
// Fetch response from server
const api = fetch(url,{
signal: this.controller.signal,
headers: {
"Content-Type": "text/html"
}
});
const result = Promise.race([api,timeout]);
result.then(response => {
if(!response.ok) {
this.status("oh no, something went wrong","error");
throw new Error("Invalid response from server");
}
return response.text();
})
.then(html => this.output(html))
.catch(error => {});
}
// Wait until the user stops typing for a few miliseconds
queue(query) {
clearTimeout(this.throttle);
this.controller = new AbortController(); // Spawn a new AbortController for each fetch
this.throttle = setTimeout(() => this.search(query),500);
}
keyEvent(event) {
const query = event.target.value;
// Don't do the search thing if query is too weak
if(query.length < 1) {
this.controller.abort(); // Abort queued search
this.lastQuery = "";
this.status("search results will appear here as you type");
return;
}
// Pressing a modifier key (Ctrl, Shift etc.) doesn't change the query
if(query === this.lastQuery) {
return false;
}
this.lastQuery = query;
this.status("searching..");
this.queue(query);
}
}

0
public/assets/js/noscript.js Normal file → Executable file
View file

View file

@ -0,0 +1,14 @@
import { default as Glitch } from "./glitch/Glitch.mjs";
const logging = "https://victorwesterlund-logging-dnzfgzf6za-lz.a.run.app";
// Log link clicks
for(let link of document.getElementsByTagName("a")) {
link.addEventListener("click", event => {
event.preventDefault();
navigator?.sendBeacon(logging, event);
window.location.href = event.target.href;
});
}
window.glitch = new Glitch(document.body.parentElement);

View file

@ -1,9 +0,0 @@
import { default as Search } from "./modules/Search.mjs";
const searchBox = document.getElementById("search")?.getElementsByTagName("input")[0] ?? false;
const resultsContainer = document.getElementById("results");
new Search(searchBox,resultsContainer);
// Set focus on searchbox when typing from anywhere
window.addEventListener("keydown",() => searchBox.focus());

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 628 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="81.968" height="45.389"><path d="M1.172 9.641c5.062.216 7.335 9.392 8.326 13.13 1.116 4.363 1.748 8.825 2.814 13.2.833 3.43 2.456 12.139 7.651 8.584 6-4.1 8.326-13.779 10.182-20.265a119.035 119.035 0 0 0 3.014-13.471c.425-2.573 1.815-6.794.466-9.158-2.614-4.646-6.86 1.665-7.285 4.438-1.232 8.218 2.1 18.317 5.22 25.727.733 1.74 1.773 5.828 4.1 6.369s3.9-2.173 4.712-3.822a29.121 29.121 0 0 0 1.782-5.3c.325-1.174.741-5 1.865-5.6 2.623-1.349 3.115 6.469 3.264 7.443.275 1.807.491 3.971 1.6 5.5 4.687 6.494 10.108-8.717 11.306-11.331C64.5 15.661 71.425 8.343 81.134 4.438c1.474-.591.833-3.014-.667-2.406-11.606 4.679-18.575 13.229-23.595 24.394a56.539 56.539 0 0 1-2.5 5.1 6.551 6.551 0 0 1-1.1 1.8 2.66 2.66 0 0 1-3.081-.241c-.916-1.041-.691-4.279-.916-5.712a16.236 16.236 0 0 0-1.141-4.488c-1.54-3.2-4.754-3.4-6.511-.266-1.315 2.34-1.665 5.2-2.431 7.718-.375 1.191-1.4 5.362-3.455 4.654-1.207-.416-2.539-5.67-2.9-6.661a69.05 69.05 0 0 1-2.914-10.182c-.7-3.38-2.09-8.409-1.066-11.881.316-1.082 1.99-4.163 2.681-2.29a5.7 5.7 0 0 1-.2 1.973c-.25 2.173-.608 4.338-1.007 6.494Q29.3 18.1 27.723 23.646a95.743 95.743 0 0 1-3.28 9.791c-.949 2.331-6.128 12.822-8.25 7.044-2.5-6.752-2.906-14.062-5-20.914-1.482-4.812-4.08-12.147-9.991-12.4C-.4 7.1-.4 9.6 1.206 9.666Z" fill="#fff"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

28
public/error.html Executable file
View file

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Victor Westerlund</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Full-stack web developer from Stockholm, Sweden.">
<meta name="theme-color" content="#000000">
<meta property='og:title' content='Victor Westerlund'>
<meta property='og:image' content='//victorwesterlund.com/assets/media/banner.jpg'>
<meta property='og:description' content='Full-stack web developer from Stockholm, Sweden.'>
<meta property='og:url' content='https://victorwesterlund.com'>
<link rel="icon" href="/assets/media/favicon-dark.png" media="(prefers-color-scheme:no-preference)">
<link rel="icon" href="/assets/media/favicon-dark.png" media="(prefers-color-scheme:light)">
<link rel="icon" href="/assets/media/favicon-light.png" media="(prefers-color-scheme:dark)">
<link rel="stylesheet" href="/assets/css/style.css">
</head>
<body>
<div>
<div id="intro">
<h1>there is nothing here</h1>
<p>and that's all I know</p>
<a href="/">take me home -></a>
</div>
</div>
<script type="module" src="/assets/js/script.mjs"></script>
</body>
</html>

1
public/humans.txt Normal file
View file

@ -0,0 +1 @@
This website was designed and built by me (Victor Westerlund) in 2022 using code and ☕

54
public/index.html Normal file → Executable file
View file

@ -1,20 +1,58 @@
<!DOCTYPE html>
<!-- Victor Westerlund - www.victorwesterlund.com -->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Victor Westerlund</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Full-stack web developer from Stockholm, Sweden.">
<link rel="icon" href="assets/img/favicon.png">
<meta name="theme-color" content="#000000">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-2RKGE84YP9"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-2RKGE84YP9');
</script>
<meta property='og:title' content='Victor Westerlund'>
<meta property='og:image' content='//victorwesterlund.com/assets/media/banner.jpg'>
<meta property='og:description' content='Full-stack web developer from Stockholm, Sweden.'>
<meta property='og:url' content='https://victorwesterlund.com'>
<link rel="icon" href="assets/media/favicon-dark.png" media="(prefers-color-scheme:no-preference)">
<link rel="icon" href="assets/media/favicon-dark.png" media="(prefers-color-scheme:light)">
<link rel="icon" href="assets/media/favicon-light.png" media="(prefers-color-scheme:dark)">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/index.css">
</head>
<body>
<main class="hidden">
<p>victor westerlund</p>
<p><a href="https://github.com/VictorWesterlund">github</a></p>
<!--<p><a href="search">search</a></p>-->
</main>
<div>
<div id="intro">
<p>hello, my name is</p>
<h1>victor</h1>
<p>I'm a</p>
<h1>full-stack</h1>
<h1>developer</h1>
<p>from Sweden</p>
<a href="https://github.com/VictorWesterlund">my github -></a>
</div>
</div>
<div>
<div id="card">
<picture>
<source srcset="assets/media/pfp/256.webp" type="image/webp" media="(min-width: 600px)">
<source srcset="assets/media/pfp/128.webp" type="image/webp">
<source srcset="assets/media/pfp/256.jpg" type="image/jpg" media="(min-width: 600px)">
<img src="assets/media/pfp/128.jpg" alt="portrait of victor"/>
</picture>
<div>
<p>I create things with code. When I'm not creating things with code, I enjoy skiing, watching movies and some occasional gaming</p>
<p>And beyond computer science, I'm also an armchair rabbit-holer for engineering, physics and astronomy</p>
</div>
<div>
<p>...and ☕, full-time</p>
</div>
<!--<a href="contact">contact me</a>-->
</div>
</div>
<script type="module" src="assets/js/script.mjs"></script>
</body>
</html>

6
public/robots.txt Normal file → Executable file
View file

@ -1,5 +1,5 @@
User-agent: *
Disallow: /.git/
Disallow: */.git/
Disallow: /*.git$
Disallow: /./
Disallow: */./
Disallow: /*.$

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<!-- Victor Westerlund - www.victorwesterlund.com -->
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Victor Westerlund - Search</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Full-stack web developer from Stockholm, Sweden.">
<link rel="icon" href="assets/img/favicon.png">
<link rel="stylesheet" href="assets/css/style.css">
<link rel="stylesheet" href="assets/css/search.css">
</head>
<body>
<header>
<h1><a href="/">victor westerlund</a></h1>
</header>
<div id="search">
<input type="text" placeholder="start typing to search..">
</div>
<div id="results">
<p>search results will appear here as you type</p>
</div>
<script type="module" src="assets/js/search.mjs"></script>
<script nomodule defer src="assets/js/noscript.js"></script>
</body>
</html>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url>
<loc>https://victorwesterlund.com/</loc>
<lastmod>2021-02-09T06:54:02+00:00</lastmod>
</url>
</urlset>

View file

@ -1,14 +0,0 @@
<?php
class Import {
public static function file($file) {
$content = file_get_contents($file);
return $content;
}
public static function json($file) {
$contents = Import::file($file);
$json = json_decode($contents);
return $json;
}
}

View file

@ -1,47 +0,0 @@
<?php
include_once dirname(__DIR__,1)."/Globals.php";
class Database extends mysqli {
public function __construct($table) {
// Load config file from this directory
$config_path = dirname(__FILE__,1)."/config.json";
$config = Import::json($config_path);
parent::__construct();
//$this->ssl_set();
// Attempt to connect to MySQL servers in order (moving to the next on failure)
foreach($config->servers as $server) {
$db = $this->real_connect($server->host,$server->user,$server->pass,$server->db);
if($db) {
return true;
}
}
}
// Exit with error code
private function error($message) {
http_response_code(500);
header("Content-Type: application/json");
$output = json_encode([
"error" => $message
]);
die($output);
}
// Return affected rows as an array of arrays
protected function get_rows($sql) {
if(!$this->ping()) {
$this->error("No database connected");
}
$query = $this->query($sql);
$rows = [];
while($row = $query->fetch_row()) {
$rows[] = $row;
}
return $rows;
}
}

View file

@ -1,10 +0,0 @@
{
"servers": [
{
"host": "",
"user": "",
"pass": "",
"db": ""
}
]
}

View file

@ -1,87 +0,0 @@
<?php
require_once dirname(__DIR__,1)."/Globals.php";
require_once dirname(__DIR__,1)."/database/Database.php";
class Search extends Database {
public function __construct() {
parent::__construct("search");
$this->query = $this->real_escape_string($_GET["q"]); // Escape the user-provided query
// Determine response type from request header or search param
$mime_type = $_SERVER["HTTP_CONTENT_TYPE"] ? $_SERVER["HTTP_CONTENT_TYPE"] : $_GET["f"];
switch($mime_type) {
case "html":
case "text/html":
$this->get_html();
break;
default:
case "json":
case "application/json":
$this->get_json();
break;
}
}
// Perform a seach on the given query and return the results as an array
private function get_results() {
$sql = "SELECT template,title,content,href FROM `search` WHERE `title` LIKE '%{$this->query}%' OR `content` LIKE '%{$this->query}%'";
$rows = $this->get_rows($sql);
return $rows;
}
// Load HTML template from disk
private function get_html_template($name) {
$path = dirname(__FILE__,1)."/templates/${name}.html";
if(!is_file($path)) {
return $this->get_html_template("card_error_display");
}
$html = Import::file($path);
return $html;
}
// Return query as HTML from templates
private function get_html() {
$results = $this->get_results();
if(count($results) < 1) {
$results[] = ["message","info","no results 😞"];
}
// Load HTML and format each response from template
$results = array_map(function($result) {
// Use first row as template name
$template = $this->get_html_template($result[0]);
// Use remaining rows as format arguments
$format = array_shift($result);
return sprintf($template,...$result);
},$results);
header("Content-Type: text/html");
echo implode("",$results);
}
// Return query as JSON
private function get_json() {
$results = $this->get_results();
$data = [
"results" => []
];
// Assign custom keys to each value (not db columns)
foreach($results as $result) {
$data["results"][] = [
"html_template" => $result[0],
"title" => $result[1],
"content" => $result[2],
"href" => $result[3]
];
}
$json = json_encode($data);
header("Content-Type: application/json");
echo $json;
}
}

View file

@ -1,8 +0,0 @@
<div class="card">
<div>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M3 2.75A2.75 2.75 0 0 1 5.75 0h14.5a.75.75 0 0 1 .75.75v20.5a.75.75 0 0 1-.75.75h-6a.75.75 0 0 1 0-1.5h5.25v-4H6A1.5 1.5 0 0 0 4.5 18v.75c0 .716.43 1.334 1.05 1.605a.75.75 0 0 1-.6 1.374A3.25 3.25 0 0 1 3 18.75v-16zM19.5 1.5V15H6c-.546 0-1.059.146-1.5.401V2.75c0-.69.56-1.25 1.25-1.25H19.5z" fill="currentColor"/><path d="M7 18.25a.25.25 0 0 1 .25-.25h5a.25.25 0 0 1 .25.25v5.01a.25.25 0 0 1-.397.201l-2.206-1.604a.25.25 0 0 0-.294 0L7.397 23.46a.25.25 0 0 1-.397-.2v-5.01z" fill="currentColor"/></svg>
<p>%s</p>
</div>
<p>%s</p>
<p href="%s" class="button">read more</p>
</div>

View file

@ -1,4 +0,0 @@
<div class="card error">
<p><strong>There was a problem displaying this result</strong></p>
<p>This is a problem on my side, sorry about that</p>
</div>

View file

@ -1,8 +0,0 @@
<div class="card">
<div>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" preserveAspectRatio="xMidYMid meet" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M3 2.75A2.75 2.75 0 0 1 5.75 0h14.5a.75.75 0 0 1 .75.75v20.5a.75.75 0 0 1-.75.75h-6a.75.75 0 0 1 0-1.5h5.25v-4H6A1.5 1.5 0 0 0 4.5 18v.75c0 .716.43 1.334 1.05 1.605a.75.75 0 0 1-.6 1.374A3.25 3.25 0 0 1 3 18.75v-16zM19.5 1.5V15H6c-.546 0-1.059.146-1.5.401V2.75c0-.69.56-1.25 1.25-1.25H19.5z" fill="currentColor"/><path d="M7 18.25a.25.25 0 0 1 .25-.25h5a.25.25 0 0 1 .25.25v5.01a.25.25 0 0 1-.397.201l-2.206-1.604a.25.25 0 0 0-.294 0L7.397 23.46a.25.25 0 0 1-.397-.2v-5.01z" fill="currentColor"/></svg>
<p>%s</p>
</div>
<p>%s</p>
<p href="%s" class="button">read more</p>
</div>

View file

@ -1 +0,0 @@
<p class="%s">%s</p>

View file

@ -1,5 +0,0 @@
<div class="resultsFooter">
<svg id="previous"><polygon points="40,10 0,20 40,30"/></svg>
<p>showing %s/%s results<span> (query took %s seconds)</span></p>
<svg id="next"><polygon points="0,10 40,20 0,30"/></svg>
</div>