### Install and Start Memcached Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Ensure memcached is installed and running. This is a prerequisite for certain Alaveteli functionalities. ```bash sudo apt-get install memcached ``` ```bash sudo service memcached start ``` -------------------------------- ### Production Alaveteli Install Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Executes the Alaveteli installation script for a production setup. Ensure the script is downloaded first. ```bash $ sudo sh ~/install-site.sh alaveteli alaveteli alaveteli.orb.local ``` -------------------------------- ### Start Alaveteli Puma Service Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Starts the Puma web server for the Alaveteli installation after the installation is complete. ```bash $ sudo systemctl start alaveteli.puma ``` -------------------------------- ### Automatic Alaveteli Site Installation Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.7-to-3.x Use the commonlib install script to automatically upgrade Ruby and set up the Alaveteli site. This is suitable for new setups or when custom configurations are not a concern. ```shell curl -O https://raw.githubusercontent.com/mysociety/commonlib/master/bin/install-site.sh sudo sh install-site.sh alaveteli alaveteli alaveteli.192.168.64.2.nip.io ``` -------------------------------- ### Development Alaveteli Install Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Executes the Alaveteli installation script with the `--dev` flag for a development setup. Ensure you are in the parent directory of your Alaveteli source code. ```bash $ sudo sh ~/install-site.sh --dev alaveteli alaveteli alaveteli.orb.local ``` -------------------------------- ### Download Alaveteli Install Script Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Fetches the Alaveteli installation script from a remote URL to the user's home directory. ```bash $ curl https://raw.githubusercontent.com/mysociety/commonlib/master/bin/install-site.sh -o ~/install-site.sh ``` -------------------------------- ### Install Ruby Dependencies Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-ruby-1.8.7 Run the post-deployment script to install necessary Ruby dependencies after migration. ```bash script/rails-post-deploy ``` -------------------------------- ### Navigate to Alaveteli Directory (Development) Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Changes the current directory to the Alaveteli installation path after a development setup. This is where the Rails development server will be started. ```bash cd /Users/gbp/Developer/work/alaveteli # not the parent directory this time ``` -------------------------------- ### Example Nginx Configuration Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md An example Nginx configuration file for running Alaveteli behind an Nginx server. ```nginx config/nginx.conf.example ``` -------------------------------- ### Install AlaveteliFeatures Source: https://github.com/mysociety/alaveteli/blob/develop/gems/alaveteli_features/README.md Run this command after adding the gem to your Gemfile to install necessary migrations and an initializer file. ```bash $ rails g alaveteli_features:install ``` -------------------------------- ### Start Alaveteli Development Server Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Starts the Alaveteli Rails development server, binding it to all interfaces and specifying the development hosts. ```bash $ RAILS_DEVELOPMENT_HOSTS=alaveteli.orb.local bin/rails s -b 0.0.0.0 ``` -------------------------------- ### Install and Configure Transifex Client Source: https://github.com/mysociety/alaveteli/wiki/Setting-up-a-demo-site Installs the Transifex client using apt-get and setuptools, then initializes it for a Transifex host. It also pulls all translations, stores model attributes, finds new translations, and updates the general.yml configuration for a specified locale. ```bash sudo apt-get update sudo apt-get install python-setuptools sudo easy_install --upgrade transifex-client ``` ```bash sudo su - alaveteli cd $HOME tx init --host https://www.transifex.net cd $HOME/alaveteli tx pull -a -f bundle exec rake gettext:store_model_attributes bundle exec rake gettext:find sed -i 's/ es/ LOCALE/' config/general.yml ./script/rails-post-deploy ``` -------------------------------- ### Install Software Packages on Debian Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Use this command to install the list of software packages required for Alaveteli on Debian systems. It parses the config/packages file to identify and install necessary dependencies. ```bash sudo apt-get install `cut -d " " -f 1 config/packages | grep -v "^#"` ``` -------------------------------- ### Static Asset Expiration Configuration Example Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Examples for setting far-future expiration dates on static assets to improve site speed. Refer to the example configuration files for Apache (httpd.conf-example) and Nginx (nginx.conf.example). ```apache ExpiresActive On ExpiresByType text/css "access plus 1 year" ExpiresByType application/javascript "access plus 1 year" ExpiresByType image/jpg "access plus 1 year" ExpiresByType image/jpeg "access plus 1 year" ExpiresByType image/png "access plus 1 year" ExpiresByType image/gif "access plus 1 year" ``` -------------------------------- ### Navigate to Alaveteli Directory (Production) Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Changes the current directory to the Alaveteli installation path after a production setup. This is useful for running Rails commands. ```bash cd /var/www/alaveteli.orb.local/alaveteli ``` -------------------------------- ### Manual Ruby and Gem Installation with rbenv Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.7-to-3.x Manually install a specific Ruby version using rbenv, update rbenv and its plugins, configure bashrc, and install bundler. This method allows for precise version control. ```shell RBENV="$HOME/.rbenv" RUBY_VERSION=3.2.2 if [ -d "$RBENV" ]; then cd $RBENV && git pull --ff-only cd $RBENV/plugins && git pull --ff-only else git clone https://github.com/rbenv/rbenv.git "$RBENV" mkdir -p "$RBENV/plugins" git clone https://github.com/rbenv/ruby-build.git "$RBENV/plugins/ruby-build" echo "export PATH=\"$RBENV/bin:\$HOME/.gem/ruby/$RUBY_VERSION/bin:\$PATH\"" >> $HOME/.bashrc echo "eval \" $(rbenv init -)\"" >> $HOME/.bashrc source $HOME/.bashrc fi rbenv install -s $RUBY_VERSION rbenv global $RUBY_VERSION gem install bundler cd /var/www//alaveteli echo $RUBY_VERSION > .ruby-version ./script/rails-deploy-before-down ``` -------------------------------- ### Navigate to Parent Directory (Development Install) Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Changes the current directory to the parent directory of the Alaveteli source code. This is required before running the development install script. ```bash $ cd /Users/gbp/Developer/work # not you alaveteli directory ``` -------------------------------- ### Install Ruby Build System Packages Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.7-to-3.x Install necessary system packages required for building Ruby using the provided list in config/packages.ruby-build. ```shell cd /var/www//alaveteli xargs -a "config/packages.ruby-build" sudo apt-get -qq -y install ``` -------------------------------- ### Generate Logrotate Configuration Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Optionally, generate an example logrotate configuration file. Refer to the documentation for detailed instructions on setting up log rotation. ```bash rake config_files:convert FILE=config/logrotate-example ``` -------------------------------- ### Install acts_as_xapian Plugin Source: https://github.com/mysociety/alaveteli/blob/develop/lib/acts_as_xapian/README.txt Retrieve the plugin directly from the git version control system. Ensure Xapian 1.0.5 and associated Ruby bindings are also installed. ```bash git clone git://github.com/frabcus/acts_as_xapian.git vendor/plugins/acts_as_xapian ``` -------------------------------- ### Start Rails Server with Specific Binding Address Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md When starting the Rails server from a Vagrant box, specify the address to bind to. Use `-b 0.0.0.0` to bind to all addresses or `-b ` for a specific IP. ```bash bundle exec rails s -b 0.0.0.0 ``` ```bash bundle exec rails s -b 10.10.10.30 ``` -------------------------------- ### Nginx Static Asset Expiration Configuration Example Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Example Nginx configuration for setting far-future expiration dates on static assets. ```nginx location ~* \.(css|js|jpg|jpeg|png|gif)$ { expires 1y; add_header Cache-Control "public"; } ``` -------------------------------- ### Install Redis Server Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Installs the Redis server package on Debian-based systems. This is a required step for the new background job processing feature. ```bash sudo apt-get install redis-server ``` -------------------------------- ### Install Ruby Build System Packages Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.3-and-2.4 Install necessary system packages for building Ruby using the 'ruby-build' tool. This command reads package names from a configuration file. ```shell xargs -a "/var/www/alaveteli/alaveteli/config/packages.ruby-build" sudo apt-get -qq -y install ``` -------------------------------- ### Install updated pdftk from mySociety PPA Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Instructions for adding the mySociety PPA and updating package sources to install an updated version of pdftk on Ubuntu Precise. ```bash apt-get install python-software-properties add-apt-repository ppa:mysociety/alaveteli apt-get update ``` -------------------------------- ### Test Install Script with Branch Override Source: https://github.com/mysociety/alaveteli/wiki/Testing-install-scripts Executes the Alaveteli installation script, overriding the default branch with a specified one using the `BRANCH_OVERRIDE` environment variable. This is useful for testing unreleased changes. ```bash $ sudo BRANCH_OVERRIDE=develop sh ~/install-site.sh alaveteli alaveteli alaveteli.orb.local ``` -------------------------------- ### Install rbenv on Debian Wheezy Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-ruby-1.8.7 Installs the rbenv version manager using apt-get. This is the first step for managing Ruby versions on Debian. ```bash sudo apt-get install rbenv ``` -------------------------------- ### Install rbenv on Ubuntu Precise Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-ruby-1.8.7 Installs the rbenv version manager on Ubuntu Precise. This command is run as the deployment user to set up per-user Ruby environments. ```bash $ ruby -v $ rbenv init The program 'rbenv' is currently not installed. To run 'rbenv' please ask your administrator to install the package 'rbenv' $ sudo apt-get install rbenv Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed rbenv 0 to upgrade, 1 to newly install, 0 to remove and 45 not to upgrade. Need to get 15.3 kB of archives. After this operation, 79.9 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu/ precise/universe rbenv all 0.1.2+git20100922-1 [15.3 kB] Fetched 15.3 kB in 0s (150 kB/s) Selecting previously unselected package rbenv. (Reading database ... 81080 files and directories currently installed.) Unpacking rbenv (from .../rbenv_0.1.2+git20100922-1_all.deb) ... Processing triggers for man-db ... Setting up rbenv (0.1.2+git20100922-1) ... $ rbenv init # Load rbenv automatically by adding # the following to ~/.bash_profile: eval "$(rbenv init -)" $ echo 'eval "$(rbenv init -)"' >> ~/.bashrc $ rbenv versions $ rbenv alternatives $ rbenv versions 1.8.7-debian 1.9.3-debian ``` -------------------------------- ### Remove Cosmic Preferences for Ubuntu Install Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Before installing Alaveteli on Ubuntu, remove the cosmic preferences from /etc/apt/preferences to avoid conflicts. ```bash Package: * Pin: release n=cosmic Pin-Priority: 50 ``` -------------------------------- ### Sentinel Entrypoint Script Source: https://github.com/mysociety/alaveteli/wiki/Docker-dev:-Redis-sentinel This script is used as an entrypoint for the Redis Sentinel Docker image. It allows for dynamic configuration of quorum, down-after, and failover timeouts by replacing placeholders in the sentinel.conf file before starting the Redis server in sentinel mode. ```shell #!/bin/sh sed -i "s/\$SENTINEL_QUORUM/$SENTINEL_QUORUM/g" /redis/sentinel.conf sed -i "s/\$SENTINEL_DOWN_AFTER/$SENTINEL_DOWN_AFTER/g" /redis/sentinel.conf sed -i "s/\$SENTINEL_FAILOVER/$SENTINEL_FAILOVER/g" /redis/sentinel.conf redis-server /redis/sentinel.conf --sentinel ``` -------------------------------- ### Enable and Reload Sidekiq Service Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Configures Sidekiq to start automatically on server boot and reloads the systemd daemon. This is required for background job processing. ```bash systemctl enable alaveteli.sidekiq.service systemctl daemon-reload ``` -------------------------------- ### Install Ruby 2.6.7 via Rbenv Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.3-and-2.4 Manually install Ruby version 2.6.7 using Rbenv and ruby-build. This includes cloning Rbenv and ruby-build repositories, configuring Rbenv, and setting up the environment variables. ```shell RBENV="$HOME/.rbenv" RUBY_VERSION=2.6.7 git clone https://github.com/rbenv/rbenv.git "$RBENV" cd $RBENV && src/configure && make -C src mkdir -p "$RBENV/plugins" git clone https://github.com/rbenv/ruby-build.git "$RBENV/plugins/ruby-build" echo "export PATH=\"$RBENV/bin:\$HOME/.gem/ruby/$RUBY_VERSION/bin:\$PATH\"" >> $HOME/.bashrc echo "eval \"\ ounrbenv init -)\"" >> $HOME/.bashrc source $HOME/.bashrc rbenv install -s $RUBY_VERSION rbenv global $RUBY_VERSION gem install bundler cd /var/www/alaveteli/alaveteli ./script/rails-deploy-before-down ``` -------------------------------- ### Get Alaveteli Version (JSON) Source: https://context7.com/mysociety/alaveteli/llms.txt Fetch the current Alaveteli application version in JSON format. This is useful for tracking deployments and compatibility. ```bash curl https://www.whatdotheyknow.com/version.json # => { "version": "0.46.5.0" } ``` -------------------------------- ### Get Alaveteli Version (XML) Source: https://context7.com/mysociety/alaveteli/llms.txt Retrieve the current Alaveteli application version in XML format. This endpoint provides an alternative format for version information. ```bash curl https://www.whatdotheyknow.com/version.xml # => 0.46.5.0 ``` -------------------------------- ### Run Rails Post-Deploy Script Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Execute this command after deployment to handle dependency installation, compilation, and other post-deployment tasks. It is essential for setting up the application correctly. ```bash ./script/rails-post-deploy ``` -------------------------------- ### Configure Exim for Mail Handling Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-ruby-1.8.7 Update Exim configuration in aliases to pipe incoming mail to Alaveteli scripts, supporting both system-wide and rbenv Ruby installations. ```exim #^foi\+.*: "|/home/alaveteli/run-with-rbenv-path /var/www/alaveteli/script/mailin", backupfoi ``` ```exim #user-support: "|/home/alaveteli/run-with-rbenv-path /var/www/alaveteli/script/handle-mail-replies" ``` -------------------------------- ### Cron Job for Public Body Stats Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Example cron job configuration to update public body statistics daily. Refer to the provided link for the exact configuration. ```cron config/crontab-example ``` -------------------------------- ### Run Post-Deploy Script Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Execute the standard post-deployment script after checking out a new version. ```bash rails-post-deploy ``` -------------------------------- ### Create Dataset Keys for a Project Source: https://github.com/mysociety/alaveteli/wiki/Alaveteli-Projects This Ruby code demonstrates how to create a `Dataset::KeySet` and individual `Dataset::Key` objects for a project. Ensure that the `order` attribute is unique for each key within a `KeySet`. ```ruby p = Project.find(1) ks = Dataset::KeySet.create(resource: p) k1 = Dataset::Key.create(key_set: ks, title: 'Is there anything of interest in this request?', format: 'text', order: 1) k2 = Dataset::Key.create(key_set: ks, title: 'Did they attach a spreadsheet?', format: 'boolean', order: 2) k3 = Dataset::Key.create(key_set: ks, title: 'How many things are there?', format: 'numeric', order: 3) ``` -------------------------------- ### Create a Project in Alaveteli Source: https://github.com/mysociety/alaveteli/wiki/Alaveteli-Projects Use this Ruby code to create a new project, assigning an owner, title, and briefing. You can also add existing requests or batches and contributors to the project. ```ruby user = User.find_by(email: 'annie@localhost') project = Project.create( owner: user, title: 'My first project', briefing: '

Collaborate!

' ) # Examples of how to add requests or batches # Note that your user needs to have these already created project.batches << user.info_request_batches.last project.requests << user.info_requests.where(info_request_batch_id: nil).last # Add some contributors project.contributors << User.find_by(email: 'bob@localhost') ``` -------------------------------- ### Enable a Feature Source: https://github.com/mysociety/alaveteli/blob/develop/gems/alaveteli_features/README.md Configure your features in the initializer file by enabling them using the Flipper backend. ```ruby AlaveteliFeatures.backend.enable(:feature_name) ``` -------------------------------- ### Run Database Migrations Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md After updating Alaveteli, run the database migrations to apply any necessary structure updates. ```bash bundle exec rails db:migrate ``` -------------------------------- ### Third-Party Webhook URL Example Source: https://github.com/mysociety/alaveteli/wiki/ActionMailbox-Migration-Guide Example of a webhook URL for a third-party email service. The format may vary; consult provider documentation for authentication methods like basic auth, secret headers, or query parameters. ```url https://actionmailbox:INGRESS_PASSWORD@example.com/rails/action_mailbox/sendgrid/inbound_emails ``` -------------------------------- ### Get Unhappy Info Request States Source: https://context7.com/mysociety/alaveteli/llms.txt Retrieves a list of states that are considered 'unhappy' for follow-up prompts. ```ruby InfoRequest::State.unhappy # => ["partially_successful", "rejected", "waiting_response_very_overdue"] ``` -------------------------------- ### Get All InfoRequest States Source: https://context7.com/mysociety/alaveteli/llms.txt Retrieves a list of all valid states for an InfoRequest, including any custom states defined by themes. ```ruby # All valid states (including any theme-defined custom states) InfoRequest::State.all # => ["waiting_response", "waiting_clarification", "gone_postal", ...] ``` -------------------------------- ### Replace Dispatcher.to_prepare with Rails.configuration.to_prepare Source: https://github.com/mysociety/alaveteli/blob/develop/doc/THEMES-UPGRADE.md The `Dispatcher.to_prepare` block should be replaced with `Rails.configuration.to_prepare` for Rails 3 compatibility. ```ruby require 'dispatcher' Dispatcher.to_prepare do ``` ```ruby Rails.configuration.to_prepare do ``` -------------------------------- ### Run Database Migrations Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Execute database schema updates required for the new release. This is a mandatory step. ```bash bin/rails db:migrate ``` -------------------------------- ### Get Short Description of InfoRequest State Source: https://context7.com/mysociety/alaveteli/llms.txt Provides a human-readable, short description for a given InfoRequest state, suitable for UI display. ```ruby # Short description for UI display InfoRequest::State.short_description('waiting_response') # => "Awaiting response" InfoRequest::State.short_description('rejected') # => "Refused" InfoRequest::State.short_description('partially_successful') # => "Partially successful" ``` -------------------------------- ### Make defer script executable Source: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-ruby-1.8.7 Make the created defer script executable. This allows the system to run the script when needed. ```bash chmod a+x /var/www/alaveteli/script/defer ``` -------------------------------- ### Pull All Translations with Transifex Client Source: https://github.com/mysociety/alaveteli/wiki/Release-Manager's-checklist This command pulls all translation files from Transifex, overwriting local files. Ensure transifex-client is installed and configured. ```bash tx pull -a -f ``` -------------------------------- ### Get Batch-Excluded Public Body Tags Source: https://context7.com/mysociety/alaveteli/llms.txt Retrieves a list of tags that are used to exclude public bodies from batch processing or UI display. ```ruby # Batch-excluded bodies (not shown in batch request UI) PublicBody.batch_excluded_tags # => ["not_apply", "defunct"] ``` -------------------------------- ### Capistrano service init script templates Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Templates for creating the alaveteli service init script for Capistrano deployments. Choose between thin or passenger based on your application server. ```text config/sysvinit-thin.ugly ``` ```text config/sysvinit-passenger.ugly ``` -------------------------------- ### Run Database Migrations Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Apply necessary database structure updates by running the database migration rake task. ```bash bundle exec rake db:migrate ``` -------------------------------- ### Configure Postfix for ActionMailbox Source: https://github.com/mysociety/alaveteli/wiki/ActionMailbox-Migration-Guide Update your Postfix `master.cf` to use ActionMailbox for email ingestion. Ensure the path, URL, and ingress password are correct for your setup. ```postfix # ActionMailbox ingestion alaveteli unix - n n - - pipe flags=R user=alaveteli argv=/path/to/alaveteli/bin/rails action_mailbox:ingress:postfix URL=https://example.com/rails/action_mailbox/postfix/inbound_emails INGRESS_PASSWORD=your_ingress_password ``` -------------------------------- ### Configure responsive styling Source: https://github.com/mysociety/alaveteli/blob/develop/doc/CHANGES.md Set the RESPONSIVE_STYLING option in config/general.yml to enable or disable responsive stylesheets. Set to true to enable, false to keep fixed-width. ```yaml RESPONSIVE_STYLING: true ``` -------------------------------- ### Print Project and Invite URLs Source: https://github.com/mysociety/alaveteli/wiki/Alaveteli-Projects This Ruby code snippet prints the direct project URL and the invite URL for a given project. The invite URL uses the project's `invite_token` and is intended for contributors. ```ruby # TODO: Use route helpers puts "Project URL: " << "https://www.whatdotheyknow.com#{app.project_path(project)}" puts "Invite URL: " << "https://www.whatdotheyknow.com/p/#{project.invite_token}" ``` -------------------------------- ### Push Translations to Transifex Source: https://github.com/mysociety/alaveteli/wiki/Release-Manager's-checklist Uploads source and translated files to Transifex. Use '--skip' to avoid pushing unsupported locales like 'en_RW'. ```bash tx push -s -t --skip ``` ```bash tx push -s -t --skip -l en ```