The content management system for the Public Lab research community, the plots2
web application is a combination of a group research blog -what we call "research notes"-and a wiki. Read more about the data model here.
Begin running (and contributing to) this codebase immediately with GitPod:
It showcases a variety of features that help the Public Lab community collaborate on environmental technology, design, documentation, and community organizing. Originally a Drupal site, it was rewritten in 2012 with Ruby on Rails and has since extended but not yet entirely replaced the legacy Drupal data model and database design. We β€οΈ Open Source and actively participate in various OSS programs such as Google Summer of Code(GSoC), Rails Girls Summer of Code (RGSoC), Outreachy, and Google Code-In (GCI). Some key features include:
- A Q&A portal for peer-based problem solving
- A rich text and Markdown editor
- Wiki editing and revision tracking
- Tagging and topically-based groups and content organization
- Email notification subscriptions for topics and comments
- A search interface built out of our growing API
- A user dashboard presenting recent activity
- A privacy-sensitive, Leaflet-based location tagging system and community map
We are developing a draft Roadmap for plots2
and our broader Public Lab code projects; read more and comment here.
A full description of the features, audiences, inter-relationships, and goals of Public Lab software projects can be found here: https://publiclab.org/software-overview
- What Makes This Project Different
- Data model
- Contributing
- Prerequisites
- Installation
- SSL in Development
- Login
- Testing
- Maintainers
- How to start and modify cron jobs
- Bundle Exec
- Reply-by-email
- Bugs and Support
- Recaptcha
- Internationalization
- Security
- Developers
- First Time?
- Hacktoberfest
The people who create our platform make very different design and technology decisions from other projects. This stems from our deep belief that, to see a change in the world, we must build and maintain systems that reflect our values and principles.
From design to system architecture to basic vocabulary and communication patterns, our systems have grown organically since 2010 to support a powerful, diverse, and cooperative network of people capable of taking on environmental problems that affect communities globally. The platform we have built together speaks to this shared history in many ways, big and small. It reflects input from people facing serious health issues, on-the-ground organizers, policy specialists, hardware hackers, educators, and civil servants.
This broad community and the Public Lab team have facilitated a space where we can discuss, break down, construct, prototype, and critique real-world projects. Together we have shaped a platform that incorporates familiar pieces but ultimately looks and feels quite different from anything else on the internet. Despite the growth of our platform, it remains committed to hearing the voices of others, mutual respect and support, an awareness of the barriers and challenges presented by gaps in expertise and knowledge, and a sensitivity to the inequalities and power imbalances perpetuated by many mainstream modes of knowledge production and technological and scientific development.
Our mutual aim to democratize inexpensive and accessible do-it-yourself techniques has allowed us to create a collaborative network of practitioners who actively re-imagine the human relationship with the environment. Our goals are supported and facilitated by a system which questions and even challenges how collaborative work can happen.
(Above: draft of our Data model)
We welcome contributions, and are especially interested in welcoming first time contributors. Read more about how to contribute below! We especially welcome contributions from people belonging to groups under-represented in free and open source software!
Please read and abide by our Code of Conduct; our community aspires to be a respectful place both during online and in-Βperson interactions.
For installation, prerequisites include sqlite3 and rvm. Click here for a complete list and instructions.
- Fork our repo from https://github.com/publiclab/plots2.
- In the console, download a copy of your forked repo with
git clone https://github.com/your_username/plots2.git
whereyour_username
is your GitHub username. - Enter the new plots2 directory with
cd plots2
. - Set the upstream remote to the original repository url so that git knows where to fetch updates from in future:
git remote add upstream https://github.com/publiclab/plots2.git
- Steps to install gems:
- You may need to first run
bundle install
if you have older gems in your environment from previous Rails work. If you get an error message likeYour Ruby version is 2.x.x, but your Gemfile specified 2.7.3
then you need to install the ruby version 2.7.3 usingrvm
orrbenv
.- Using rvm:
rvm install 2.7.3
followed byrvm use 2.7.3
- Using rbenv:
rbenv install 2.7.3
followed byrbenv local 2.7.3
- Using rvm:
- Run this
bundle config set without 'production mysql'
from the rails root folder to set your project to exclude libraries only needed in production. - Install gems with
bundle install
from the rails root folder.
- You may need to first run
- Run
cp db/schema.rb.example db/schema.rb
to make a copy ofdb/schema.rb.example
indb/schema.rb
. - You could choose to use mysql2 or sqlite3 as your database. We recommend using
sqlite3
as your plots2 database as some of our contributors have reported issues while usingmysql2
.- If mysql2, run
cp config/database.yml.mysql.example config/database.yml
to make a copy ofconfig/database.yml.mysql.example
inconfig/database.yml
- If sqlite3, run
cp config/database.yml.sqlite.example config/database.yml
to make a copy ofconfig/database.yml.sqlite.example
inconfig/database.yml
. kindly note if you choose to use sqlite some tests may fail. The project was setup initially to use mysql and some tests are tailored for mysql db. No need for alarm, we are working to fix these and this will not interfere with your development process
- If mysql2, run
- Run
rake db:setup
to set up the database - Install static assets (like external javascript libraries, fonts) with
yarn install
- Setup React & webpacker by running
rails webpacker:install && rails webpacker:install:react && rails generate react:install
(for local SSL work, see SSL below)
- If you get any prompt to overwrite files in this step please choose no. The prompt will be something like "Overwrite /home/plots2/config/webpacker.yml? (enter "h" for help) [Ynaqdhm]" :- type "n" and enter.
- Start the server with
passenger start
and navigate tohttp://localhost:3000/
on your browser. - Wheeeee! You're up and running! Log in with test usernames "user", "moderator", or "admin", and password "password".
- Run
rails test
to confirm that your install is working properly. You can also runrails test:system
for system tests. (Note: if you chose sqlite as your database, some tests may fail; Please ignore these, we are working to fix this. If your server starts correctly, you are all set)
We recommend you either work in a virtual environment, or on a dual booted system to avoid dependencies issues as Unix systems tend to work smoother with Ruby and Rails. This will not only benefit you now for plots2, but also in the future while working on other Ruby projects, a Linux or Mac based OS will make your development much easier.
- Windows Subsystem for Linux (recommended)
- Dual Booting, option2, video guide
- Setting up a Linux virtual env
Before continuing with the installation steps in this README, users of Windows Subsystem for Linux 2 (WSL 2) should open the WSL 2 Terminal and type out the commands below.
- Install Dependencies required from Ruby Source with the following commands:
sudo apt update
sudo apt install curl g++ gcc autoconf automake bison libc6-dev
sudo apt install libffi-dev libgdbm-dev libncurses5-dev libsqlite3-dev libtool
sudo apt install libyaml-dev make pkg-config sqlite3 zlib1g-dev libgmp-dev
sudo apt install libreadline-dev libssl-dev
- Add GPG Key & Install RVM:
- Install gnupg2 if you haven't already:
sudo apt install gnupg2
gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable
- Load the Script environment variables using source command:
source ~/.rvm/scripts/rvm
- Install and use specific Ruby version:
rvm install ruby-x.x.x (this projects Ruby version)
rvm --default use ruby-x.x.x (replace x.x.x with this project's Ruby version)
- For further reference, read here
Public Lab uses Redis and may be required for some functionality when running the application locally.
- Install Redis if you haven't already:
- Using MacOS:
brew install redis
- Using Linux:
sudo yum -y install redis
- Using Ubuntu WSL2:
- update & upgrade Ubuntu:
sudo apt update && apt upgrade
- install redis:
sudo apt install Redis-server
- open Redis.config file:
sudo nano /etc/redis/redis.conf
- update the file by changing the supervised no line to supervised systemd(ubuntu uses systemd)
- start Redis:
sudo service redis-server start
- open Redis CLI:
redis-cli
- test Redis: type
ping
& response should bepong
- exit cli: type
quit
- Awesome π All done β
- update & upgrade Ubuntu:
- Run Redis server:
- Using MacOS:
brew services start redis
- Using Linux:
redis-server
- Run SideKiq:
bundle exec sidekiq
- If SideKiq started correctly Redis is now configured and working!
At Public Lab we use the openssl gem to provide SSL (Secure Sockets Layer) for a secure connection (https) in the development mode. You can run the https connection on localhost through the following steps:
- Use
passenger start --ssl --ssl-certificate config/localhost.crt --ssl-certificate-key config/localhost.key --ssl-port 3001
. - Open up https://localhost:3001.
- Add security exceptions from the advance settings of the browser. You can also use http (unsecure connection) on the port number 3000 by going to 'http://localhost:3000'. We use port number 3001 for 'https' and port number 3000 for 'http' connection. Secure connection is needed for OAuth authentication etc.
Once you complete the installation, use any of these credentials to login into the PL website in your local development/testing environment to gain additional permissions for logged in users only. Each one comes with its own set of permissions; nevertheless, the experience across them is pretty much the same.
username: admin
, moderator
, or user
password: password
For more on the login systems, see this page
Click here for a comprehensive description of testing and here to learn about system tests.
- See /doc/MAINTAINERS.md for Public Lab's policy on feature maintainers!
- We are using Whenever gem to schedule cron jobs.
- All the cron jobs are written in easy ruby syntax using this gem and can be found in config/schedule.rb.
- Go to the config/schedule.rb file to create and modify the cron jobs.
- Click here to learn more about how to write cron jobs.
- After updating config/schedule.rb file run the command
whenever --update-crontab
to update the cron jobs. - To see the installed list of cron jobs use command
crontab -l
- For more details about this gem, visit the official repository of the Whenever gem.
For some, it will be necessary to prepend your gem-related commands with bundle exec
.
For example, bundle exec passenger start
.
Adding bundle exec
ensures you're using the version of passenger you just installed with Bundler.
bundle exec rake db:setup
, bundle exec rake db:seed
are other examples of where this might be necessary.
Public Lab now supports "reply by email to comment" feature. For more details, go to the email documentation
To report bugs and request features, please use the GitHub issue tracker
For additional support, join the Public Lab website and mailing list at http://publiclab.org/lists. For urgent requests, email [email protected]
This application uses RECAPTCHA via the recaptcha gem in production only. For more information, click here.
Publiclab.org now supports Internationalization and localization, though we are in the initial stages. This has been accomplished with rails-I8n.
To see it in action, click on the 'Language' drop-down located in the footer section of the page. All the guidelines and best practices for I18n can be found here.
Translations are arranged in the YAML files here, which are set in a similar way to views files. An example for adding translations can be found here.
Since the implementation of our new Translation system, we now use the translation()
helper, found here. This provides some extra translation features such as inserting a prompt visible to site visitors if no translation exists yet. You can learn more about our translation system by reading our Translation system docs.
To add new languages or for additional support, please write to [email protected]
To report security vulnerabilities or for questions about security, please contact [email protected]. Our Web Working Group will assess and respond promptly.
Help improve Public Lab software!
- Join the [email protected] discussion list to get involved
- Look for open issues at https://github.com/publiclab/plots2/labels/help-wanted
- We're specifically asking for help with issues labelled with help-wanted tag
- Find lots of info on contributing at http://publiclab.org/wiki/developers
- Review specific contributor guidelines at http://publiclab.org/wiki/contributing-to-public-lab-software
- Some devs hang out in the irc webchat
- Join our gitter chat
- Try out some supportive tasks
- Get involved with our weekly community check-ins. For guidelines: https://github.com/publiclab/plots2/tree/main/doc/CHECKINS.md
- You can help us by opening first timers issues or fto. The template for opening an issue can be found at https://github.com/publiclab/plots2/blob/main/.github/ISSUE_TEMPLATE/--first-timers-only.md
New to open source/free software? Here is a selection of issues we've made especially for first-timers. We're here to help, so just ask if one looks interesting : https://code.publiclab.org
Here is a link to our Git workflow.
Wishing to contribute to Publiclab as part of Hacktoberfest? Check out our Hacktoberfest contributing docs