Giter Site home page Giter Site logo

aefeertugrul / djangosnippets.org Goto Github PK

View Code? Open in Web Editor NEW

This project forked from django/djangosnippets.org

0.0 0.0 0.0 1.1 MB

The code that powers djangosnippets.org, it allows users to post and share useful "snippets" of code.

Home Page: https://djangosnippets.org

License: BSD 3-Clause "New" or "Revised" License

Shell 0.10% JavaScript 22.84% Ruby 0.27% Python 44.46% CSS 2.23% HTML 26.03% Dockerfile 0.11% SCSS 3.95% Procfile 0.02%

djangosnippets.org's Introduction

djangosnippets.org

This code is used to power the snippet sharing site, djangosnippets.org

Database Setup Using Windows

Download the latest version of PostgreSQL. Click on the executable to start the installation setup wizard.

Click Next, keeping all the defaults as you work through the wizard. Make a note of the password you choose for the database superuser (postgres). Select the default port 5432 and the default locale. After it’s finished installing, you do not need to launch Stack Builder. Un-tick that box if you are asked, and click Finish.

Open SQL Shell (psql). In the shell, select the default values for Server, Database, Port and Username (basically, press Enter four times).

Type in the password you noted earlier and press enter. Run the command below, taking care to include the semi-colon.

$ CREATE DATABASE djangosnippets;

Close SQL Shell (psql).

You need to copy .env.example to env.bat and configure to your needs. Use the template below, taking care to include set at the start of each line, and to substitute the password you noted earlier into DATABASE_URL. For development, DEBUG is set to True.

set REDISTOGO_URL=redis://redis:6379/0
set SECRET_KEY=p_o3vp1rg5)t^lxm9-43%0)s-=1qpeq%o7gfq+e4#*!t+_ev82
set DEBUG=True
set ALLOWED_HOSTS=0.0.0.0,127.0.0.1
set DATABASE_URL=postgres://postgres:your_password@:5432/djangosnippets
set DJANGO_SETTINGS_MODULE=djangosnippets.settings.development
set SEARCHBOX_SSL_URL=http://elasticsearch:9200/
set SESSION_COOKIE_SECURE=False

Go back to your terminal. You will need to run the command below whenever you open a new terminal.

$ env.bat

Your environment variables are now set and you can proceed with the instructions below.

Development Setup

In a Python 3.7 virtual environment:

$ cd requirements
$ pip install -r development.txt
$ cd ..
$ python manage.py migrate

Now you can start the development server:

$ python manage.py runserver

Before you can actually use the site, you have to define at least one language. If you just want to use the ones from djangosnippets.org, they are included in the fixtures folder. Also included are five snippets to get you started:

$ python manage.py createsuperuser
$ python manage.py loaddata fixtures/cab.json

You will need to build the site.css with tailwindcss:

$ npm run build

Now you should be able to use the development version of djangosnippets on port 8000.

To run tests:

$ python manage.py test --settings=djangosnippets.settings.testing

Docker

You need to copy .env.example to .env and configure to your needs. The example is fine to start with development.

You may wish to use docker locally for production dependency testing and development; here are the setup instructions:

$ docker-compose -f docker-compose.yml build
$ docker-compose -f docker-compose.yml up -d

-d denotes running docker in a detached state:

$ docker-compose -f docker-compose.yml run web python manage.py migrate
$ docker-compose -f docker-compose.yml run web python manage.py createsuperuser
$ docker-compose -f docker-compose.yml run web python manage.py loaddata fixtures/cab.json
$ npm run build
$ docker-compose -f docker-compose.yml run web python manage.py collectstatic

The docker setup is running as close as possible to the production setup in Heroku:

Postgres 12.3 Gunicorn Redis

To run our tests with docker:

$ docker-compose -f docker-compose.yml run web python manage.py test --settings=djangosnippets.settings.testing

Styling Contributor?

DjangoSnippets uses the Foundation framework as the core of its visual style. To get this working on your local machine you need compass and bower to compile your stylesheets. Please never modify the generated .css files directly. Use the .scss ones instead.

To keep the setup path as short as possible, run the following commands in your terminal:

$ cd djangosnippets/static
$ bower install && compass watch

If you don't have either of these two installed, you can find detailed instructions on their respective websites.

Please make sure that you commit only a compressed version of the CSS file as this is what will be deployed. (In order to do that the default configuration inside djangosnippets/static/config.rb is output_style = :compressed)

Production Setup

The production setup is currently tailored to Heroku and, therefore, mostly automatic. The difference between these two setups is configured in the djangosnippets.settings.production module and the requirements.txt file.

djangosnippets.org's People

Contributors

jezdez avatar timgraham avatar dependabot-preview[bot] avatar coleifer avatar zerok avatar dependabot[bot] avatar chriswedgwood avatar stephrdev avatar barttc avatar dplanella avatar ppmdo avatar daniboygg avatar sijanonly avatar hashlash avatar alexander-ae avatar vivekthedev avatar rixx avatar santos22 avatar markush avatar felixxm avatar manaswinidas avatar lucassd avatar jefftriplett avatar gostich avatar carltongibson avatar brylie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.