Skip to content

Instantly share code, notes, and snippets.

@anon987654321
Created February 23, 2025 20:34
Show Gist options
  • Save anon987654321/f41b69fb3208cf611400ebe850b7505a to your computer and use it in GitHub Desktop.
Save anon987654321/f41b69fb3208cf611400ebe850b7505a to your computer and use it in GitHub Desktop.

hjerterom.sh

Et installasjonsskript for webapplikasjonen "Hjerterom". Inspirert av www.lafoodbank.org. Se også https://medium.com/@oowae5a/openbsd-vs-linux-for-ruby-on-rails-c3bb40791632 for hvorfor jeg har valgt nettopp Rails (se ny dokumentar: https://www.youtube.com/watch?v=HDKUEXBF3B4) og OpenBSD fremfor alle andre alternativ.

#!/bin/zsh
#
# hjerterom.sh
#
# - Redistribution of food waste and periodic giveaways of electronics via on-site collection.
# - A public interface for users to see opening times, events, and their location on a map.
# - An admin interface to help owners effectively run Hjerterom, manage events/opening times, and monitor operations.
# - Secure, multi-channel authentication with Norwegian BankID/Vipps (OAuth).
# - Centralized social media sharing, post scheduling, and enriched meta-tag generation.

set -e

# Constants
APP_NAME="hjerterom"
BASE_DIR="$HOME/dev/rails_apps"

# Load shared functions from __shared.sh (ensure this file is version-controlled and available)
source "$BASE_DIR/__shared.sh"

log "Starting Hjerterom installation (Production-Ready for the Norwegian community with admin management)"

# Initial project setup
initialize_setup "$APP_NAME"
setup_yarn
create_rails_app "$APP_NAME" --rails-version 8 --pwa

cd "$APP_NAME"

# Install common Ruby gems and configure Rails features
log "Installing common gems and configuring core Rails features"
install_common_gems

# Configure authentication using Devise: Enable anonymous logins (devise-guests) and OAuth for BankID/Vipps
log "Setting up Devise with support for anonymous logins and OAuth (BankID/Vipps)"
setup_devise --enable-guests --enable-oauth="bankid,vipps" || error_exit "Devise setup failed"

# Integrate Hotwire and StimulusReflex for real-time interactions
log "Integrating Hotwire and StimulusReflex for live features"
setup_stimulus_reflex

# Configure Progressive Web App settings
log "Configuring PWA settings and AI integration"
setup_pwa

# Configure internationalization (i18n) for Norwegian Bokmål locales
log "Setting up Norwegian Bokmål locale files"
setup_i18n "nb"

# Integrate centralized social features (social sharing, scheduling, and content moderation)
log "Integrating centralized social media features"
setup_social_features

# Generate models and controllers for community interactions
log "Generating models and controllers for Post"
bin/rails generate model Post content:text user:references published:boolean || error_exit "Post model generation failed"
bin/rails generate controller Posts index show new create edit update destroy || error_exit "Posts controller generation failed"

# Generate models and controllers for admin functionalities
log "Generating admin models and controllers for event and location management"
bin/rails generate model Event title:string description:text start_time:datetime end_time:datetime location:string latitude:float longitude:float || error_exit "Event model generation failed"
bin/rails generate controller Admin::Dashboard index || error_exit "Admin dashboard generation failed"
bin/rails generate controller Admin::Events index show new create edit update destroy || error_exit "Admin events controller generation failed"

log "Hjerterom installation finished successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment