Skip to content
This repository has been archived by the owner on May 17, 2018. It is now read-only.

Commit

Permalink
Initial discourse integration
Browse files Browse the repository at this point in the history
Signed-off-by: Matheus Fernandes <[email protected]>
  • Loading branch information
msfernandes committed Dec 6, 2017
1 parent f9eedd1 commit f5032fc
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 7 deletions.
2 changes: 1 addition & 1 deletion colab/management/commands/initdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Command(BaseCommand):
help = ('Create admin and set site domain')

def handle(self, *args, **kwargs):
self.create_admin()
self.set_site_domain()
self.create_admin()

def set_site_domain(self):
site = Site.objects.get_current()
Expand Down
101 changes: 95 additions & 6 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- colab_assets:/var/labhacker/colab/public:z
- audiencias:/var/labhacker/audiencias:z
- wikilegis:/var/labhacker/wikilegis:z
- discourse:/var/www/discourse:z
ports:
- "8000:80"
links:
Expand All @@ -16,17 +17,16 @@ services:
NAME_RESOLVER: '127.0.0.11'

db:
image: postgres
image: postgres:9.6
environment:
POSTGRES_USER: root
POSTGRES_PASSWORD: root
POSTGRES_DB: root
PGDATA : /var/lib/postgresql/data/
volumes:
- colab_data:/var/lib/postgresql/data/
- pg_data:/var/lib/postgresql/data/

colab:
# build: .
image: labhackercd/edemocracia-colab
command: ./start-colab.sh
environment:
Expand Down Expand Up @@ -61,8 +61,12 @@ services:
SITE_BACKGROUND_IMAGE: ''
ENABLE_AUDIENCIAS: 'true'
ENABLE_WIKILEGIS: 'true'
ENABLE_DISCOURSE: 'true'
AUDIENCIAS_API_KEY: secret_key
WIKILEGIS_API_KEY: api_key
DISCOURSE_API_KEY: api_key
DISCOURSE_API_USERNAME: system
DISCOURSE_SSO_SECRET: sso_secret
volumes:
- colab_assets:/var/labhacker/colab/public:z
links:
Expand Down Expand Up @@ -111,7 +115,12 @@ services:
ADMIN_PASSWORD: 123
ADMIN_EMAIL: [email protected]
ADMIN_USERNAME: admin
DATABASE_URL: postgres://root:root@db:5432/audiencias
DATABASE_ENGINE: postgresql_psycopg2
DATABASE_NAME: audiencias
DATABASE_PASSWORD: root
DATABASE_USER: root
DATABASE_HOST: db
DATABASE_PORT: 5432
DEBUG: 'False'
REDIS_SERVER: redis
WEBSERVICE_URL: https://infoleg.camara.leg.br/ws-pauta/evento/interativo
Expand Down Expand Up @@ -155,7 +164,12 @@ services:
ADMIN_PASSWORD: 123
ADMIN_EMAIL: [email protected]
ADMIN_USERNAME: admin
DATABASE_URL: postgres://root:root@db:5432/audiencias
DATABASE_ENGINE: postgresql_psycopg2
DATABASE_NAME: audiencias
DATABASE_PASSWORD: root
DATABASE_USER: root
DATABASE_HOST: db
DATABASE_PORT: 5432
DEBUG: 'False'
REDIS_SERVER: redis
WEBSERVICE_URL: https://infoleg.camara.leg.br/ws-pauta/evento/interativo
Expand Down Expand Up @@ -212,11 +226,86 @@ services:
depends_on:
- db

discourse:
image: labhackercd/discourse-docker
command: ./start-web.sh
volumes:
- discourse:/var/www/discourse
expose:
- "8080"
depends_on:
- db
- redis
- sidekiq
environment:
RAILS_ENV: 'production'
DISCOURSE_DB_HOST: db
DISCOURSE_DB_PORT: '5432'
DISCOURSE_DB_NAME: 'root'
DISCOURSE_DB_USERNAME: 'root'
DISCOURSE_DB_PASSWORD: 'root'
DISCOURSE_HOSTNAME: 'localhost'
DISCOURSE_SMTP_ADDRESS: smtp.gmail.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: '[email protected]'
DISCOURSE_SMTP_PASSWORD: '19930113'
DISCOURSE_DEVELOPER_EMAILS: '[email protected]'
DISCOURSE_REDIS_HOST: 'redis'
DISCOURSE_REDIS_PORT: 6379
DISCOURSE_RELATIVE_URL_ROOT: '/expressao'
DISCOURSE_CONTACT_EMAIL: '[email protected]'
DISCOURSE_CONTACT_URL: 'localhost'
DISCOURSE_NOTIFICATION_EMAIL: '[email protected]'
DISCOURSE_LOGO_URL: '\/images\/d-logo-sketch.png'
DISCOURSE_SMALL_LOGO_URL: '\/images\/d-logo-sketch-small.png'
DISCOURSE_FAVICON_URL: '\/images\/default-favicon.ico'
DISCOURSE_APPLE_TOUCH_ICON_URL: '\/images\/default-apple-touch-icon.png'
DISCOURSE_SSO_URL: 'http:\/\/127.0.0.1:8000'
DISCOURSE_SSO_SECRET: 'sso_secret'
DISCOURSE_FORCE_HOSTNAME: ''

sidekiq:
image: labhackercd/discourse-docker
command: './start-sidekiq.sh'
depends_on:
- db
- redis
volumes:
- discourse:/var/www/discourse
environment:
RAILS_ENV: 'production'
DISCOURSE_DB_HOST: db
DISCOURSE_DB_PORT: '5432'
DISCOURSE_DB_NAME: 'root'
DISCOURSE_DB_USERNAME: 'root'
DISCOURSE_DB_PASSWORD: 'root'
DISCOURSE_HOSTNAME: 'localhost'
DISCOURSE_SMTP_ADDRESS: smtp.gmail.com
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: '[email protected]'
DISCOURSE_SMTP_PASSWORD: '19930113'
DISCOURSE_DEVELOPER_EMAILS: '[email protected]'
DISCOURSE_REDIS_HOST: 'redis'
DISCOURSE_REDIS_PORT: 6379
DISCOURSE_RELATIVE_URL_ROOT: '/expressao'
DISCOURSE_CONTACT_EMAIL: '[email protected]'
DISCOURSE_CONTACT_URL: 'localhost'
DISCOURSE_NOTIFICATION_EMAIL: '[email protected]'
DISCOURSE_LOGO_URL: '\/images\/d-logo-sketch.png'
DISCOURSE_SMALL_LOGO_URL: '\/images\/d-logo-sketch-small.png'
DISCOURSE_FAVICON_URL: '\/images\/default-favicon.ico'
DISCOURSE_APPLE_TOUCH_ICON_URL: '\/images\/default-apple-touch-icon.png'
DISCOURSE_SSO_URL: 'http:\/\/127.0.0.1:8000'
DISCOURSE_SSO_SECRET: 'sso_secret'
DISCOURSE_FORCE_HOSTNAME: ''

volumes:
colab_data:
pg_data:
driver: local
colab_assets:
driver: local
discourse:
driver: local
audiencias:
driver: local
wikilegis:
Expand Down
21 changes: 21 additions & 0 deletions misc/etc/colab/plugins.d/discourse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from decouple import config

name = 'colab_discourse'
verbose_name = 'Colab Discourse Plugin Plugin'

upstream = 'http://discourse:8080/expressao/'
api_key = config('DISCOURSE_API_KEY')
api_username = config('DISCOURSE_API_USERNAME')
sso_secret = config('DISCOURSE_SSO_SECRET')

urls = {
'include': 'colab_discourse.urls',
'prefix': '^expressao/',
'login': '/expressao/accounts/login/',
}

settings_variables = {
'COLAB_STATICS': [
'/usr/lib/python2.7/site-packages/colab_discourse/static'
]
}
10 changes: 10 additions & 0 deletions misc/etc/colab/widgets.d/discourse_widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from colab.widgets.widget_manager import WidgetManager
from colab_discourse.widgets.home_section import DiscourseHomeSectionWidget
from colab_discourse.widgets.navigation_links import (
DiscourseNavigationLinksWidget
)


WidgetManager.register_widget('home_section', DiscourseHomeSectionWidget())
WidgetManager.register_widget('navigation_links',
DiscourseNavigationLinksWidget())
5 changes: 5 additions & 0 deletions start-colab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ activate_plugin() {

[[ -z "${ENABLE_AUDIENCIAS}" ]] && ENABLE_AUDIENCIAS=2 || ENABLE_AUDIENCIAS="${ENABLE_AUDIENCIAS}"
[[ -z "${ENABLE_WIKILEGIS}" ]] && ENABLE_WIKILEGIS=2 || ENABLE_WIKILEGIS="${ENABLE_WIKILEGIS}"
[[ -z "${ENABLE_DISCOURSE}" ]] && ENABLE_DISCOURSE=2 || ENABLE_DISCOURSE="${ENABLE_DISCOURSE}"

if [[ "$ENABLE_WIKILEGIS" = true ]]; then
activate_plugin wikilegis
Expand All @@ -29,6 +30,10 @@ if [[ "$ENABLE_AUDIENCIAS" = true ]]; then
activate_plugin audiencias
fi

if [[ "$ENABLE_DISCOURSE" = true ]]; then
activate_plugin discourse
fi

crond

while true; do
Expand Down

0 comments on commit f5032fc

Please sign in to comment.