Skip to content
View rolfmadsen's full-sized avatar

Block or report rolfmadsen

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
rolfmadsen/README.md

Search user interface based on FBI-API (Fælles BiblioteksInfastruktur), which is governed by KOMBIT

Full disclaimer: This project is being developed as I learn to program, so expect rookie patterns and errors.

This project is created with a Rust and serverless function backend and NextJS frontend while new code is deployed with every commit on Github to the Vercel cloud platform.

Deploy with Vercel

The discovery user interface is based on the Danish Library Infrastructure Platform (FBI API).

Releasenotes

October 2024

  • Display detailed information about works, including titles, authors, abstract, publication dates, material types, subjects, and more.
  • The page now dynamically fetches work details using the new api/work endpoint powered Rust matching the api/search endpoint.

December 2023

  • Rust backend with integration to FBI-API
  • Access token is retrieved from the Access Platform
  • Access token is reused for every API request in a browser session
  • Request parameters are mirrored in the site URL
  • Changes to URL parameters will initiate a new search request
  • New search result page
  • Skeleton screen for better perceived performance
  • Piwik Pro integration for user analytics
  • Introduction to the website

Vercel (Zeit.co) - Next.JS

I use a very simple build pipeline where every commit to Github deploys the site on the Vercel cloud platform.

After committing code to Github you can se the build process under https://vercel.com/dashboard for the corresponding project.

Example: https://rolfmadsen.dk/

Preparing your local development environment

It has been a while since I had to reestablish my local development environment, and as the setup is estblished manually, view the following chapters as inspiration as they have not recently been tested.

Ready your Ubuntu installation

I have installed Ubuntu on a laptop for my local development environment.

Update nodejs to version 14 due to dependency on this version

  curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

_Kilde: https://github.com/nodesource/distributions/blob/master/README.md#debinstall _

  sudo apt -y install nodejs
  node -v

Install Git on Ubuntu

  sudo apt update
  sudo apt install git
  git --version

Configure username and e-mail

Configure your name:

  git config --global user.name "ENTER YOUR NAME"

Configure your e-mail-addresse:

  git config --global user.email "[email protected] E-MAIL-ADDRESSE"

NB. Find your Github no-reply e-mail-adress under https://github.com/settings/emails.

See configuration:

  git config --list

Install Vercel CLI:

  npm i -g vercel
  vercel -v

NB. When running $ "vercel -v" I got the response "command not found" and had to use $ "npm install -g npm".

Github

If you clone this repository and setup a local development environment you can use the Vercel CLI to retrieve your environment variables using the "vercel env pull" command.

N.B. If you encounter the error message: "Error! The specified token is not valid" try "vercel logout" and "vercel login".

Clone repository

Clone the code repository on Github to Github directory on your local development environment.

  mkdir Github && cd Github
  git clone https//github.com/rolfmadsen/rolfmadsen.git

Install all dependencies:

  npm install

Connect your local development environment to your Vercel project

  1. Login (https://vercel.com/login) or create account (https://vercel.com/signup) on Vercel.
  2. Create a new project (https://vercel.com/new).
  3. Select "Add GitHub Org or Account".

Login to Vercel from terminal:

  vercel login

Link local development environment to Vercel project:

  vercel link

Run project on localhost for testing before you commit changes to Github:

  vercel dev

Github - Personal access token

  1. Open https://github.com/settings/tokens
  2. Click "Generate new token"
  3. Add token name
  4. Select scopes/permissions by clicking repo checkmark
  5. Click "Generate token"
  6. Copy the token to your preferred password manager
  7. Open your terminal and navigate to local project directory
  8. Remove old origin remote:
$ git remote remove origin
  1. Add new origin remote:
$ git remote add origin https://{TOKEN}@github.com/{USERNAME}/{REPOSITORY}.git

Adding a staging domain for testing changes

First set up Vercel to build a staging site when you push changes to your staging branch in your Github organization:

  1. Open https://vercel.com/[ENTER YOUR ORGANIZATION]/rolfmadsen/settings/domains
  2. Add "staging.[ENTER YOUR DOMAIN].dk"
  3. Add "https://github.com/[ENTER YOUR ORGANIZATION]/rolfmadsen/tree/staging"

Create staging branch

  git branch staging

Shift to staging branch

  git checkout staging

Perform the changes you wish on the staging branch.

Shift to master branch

  git checkout master

Add the changes made on the staging branch to the master branch.

  git merge staging

Push the merged changes on the master branch to origin (Github master branch)

  git push

Commands for pushing code to github:

Stage all changes in the current directory and sub-directories:

Show status of working tree/directory and staging area:

git status

Add or track all files from working tree/directory to staging area:

git add .

NB. Add specific files by exchanging "." with the "file-name".

See the history of changes to the repository:

  git log --all --decorate --oneline --graph

NB. You can use graph as an alias for the previous "git log" command via:

  alias graph="git log --all --decorate --oneline --graph"  

See the difference between working tree/direcotr and staging area:

  git diff

Saves all changes to the local repository:

  git commit -m "ENTER A DESCRIPTION OF THE CHANGE" 

Upload all changes from the local repository to the master of the remote repository:

  git push

NB. When you push you will be promptet to login to Github and you can use a Github Token for use as a password in the terminal under https://github.com/settings/tokens.

Get updates from remote repository:

  git pull

Close staging branch

NB. Checkout master branch before deleting staging branch.

  git checkout master
  git branch -d staging

Piwik Pro ID and URL

Piwik Pro Library for NextJS

  1. Find the Piwik ID and URL under https://{account_name}.piwik.pro/administration/apps
  2. Add Piwik variables to https://vercel.com/{account_name}/{project_name}/settings/environment-variables

NEXT_PUBLIC_CONTAINER_ID NEXT_PUBLIC_CONTAINER_URL

Styling with Tailwind CSS

components/layout.js

"""js function Layout({ children }) { return

{children}
}

export default Layout """

pages/_app.js

import '../styles/index.scss';
function App({ Component, pageProps }) {
  return <Component {...pageProps} />;
}
export default App;

styles/index.scss

@tailwind base;

h1 {
  @apply text-2xl;
}
h2 {
  @apply text-xl;
}
h3 {
  @apply text-lg;
}
a {
  @apply text-blue-600 underline;
}

@font-face {
  font-family: Proxima Nova;
  font-weight: 400;
  src: url(/fonts/proxima-nova/400-regular.woff) format("woff");
}
@font-face {
  font-family: Proxima Nova;
  font-weight: 500;
  src: url(/fonts/proxima-nova/500-medium.woff) format("woff");
}

@tailwind components;
@tailwind utilities;

html,
body,
#__next {
  height: 100%;
}

.transition-color-shadow {
  transition-property: color, background-color, box-shadow;
}

postcss.config.js

module.exports = {
  plugins: [
    'tailwindcss',
    'postcss-preset-env'
  ],
};

tailwind.config.js

module.exports = {
    purge: ['./src/components/**/*.tsx', './src/pages/**/*.tsx'],
    theme: {
      screens: {
        xsm: '414px',
        sm: '640px',
        md: '768px',
        lg: '1024px',
        xl: '1280px',
      },
      extend: {},
    },
    variants: {},
    plugins: [],
  };

Add browserlist to package.json

{
"browserslist": [">0.3%", "not ie 11", "not dead", "not op_mini all"]
}

Sources

  1. https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
  2. https://nextjs.org/learn/basics/assets-metadata-css/layout-component
  3. https://nextjs.org/learn/basics/assets-metadata-css/global-styles

Notes

  1. Consider useing PurgeCSS to removed unused styles from Tailwind CSS. (Source: https://khanna.cc/blog/using-tailwind-ui-and-next-js-together/ - 3. Optimize for production with PurgeCSS.)

Popular repositories Loading

  1. yEd-documentation yEd-documentation Public

    yEd - Graph Editor - konfiguration

    3

  2. rolfmadsen rolfmadsen Public

    JavaScript 1

  3. rolfmadsen.github.com rolfmadsen.github.com Public

    HTML

  4. sublimetext3 sublimetext3 Public

  5. ding3 ding3 Public

  6. opensearch_python_requests opensearch_python_requests Public

    Experimenting with Python requests against the Opensearch API

    Python