Skip to content

Commit

Permalink
changes requested made
Browse files Browse the repository at this point in the history
  • Loading branch information
krrish-sehgal committed Nov 7, 2024
2 parents 72e9439 + 8966395 commit b82faf6
Show file tree
Hide file tree
Showing 18 changed files with 351 additions and 216 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ jobs:

- name: Get Poetry cache directory
id: poetry-cache
# run: echo "::set-output name=dir::$(poetry config cache-dir)"
run: echo "POETRY_CACHE_DIR=$(poetry config cache-dir)" >> $GITHUB_ENV

- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: ${{ env.POETRY_CACHE_DIR }}
path: ${{ env.POETRY_CACHE_DIR }}
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}
restore-keys: |
${{ runner.os }}-poetry-
Expand Down Expand Up @@ -104,8 +103,6 @@ jobs:
with:
python-version: 3.11.2
- run: pip install poetry
- name: Ensure lock file is up to date
run: poetry lock --no-update
- run: poetry install
- run: poetry run python manage.py collectstatic --noinput
- name: Run tests
Expand Down
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ chromedriver
requirements.txt
*.code-workspace
*.log
*.exe
poetry.lock
*.exe
65 changes: 47 additions & 18 deletions Setup.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
# Setting up Development server
# Setting Up Development Server

- [Video on How to setup Project BLT](https://www.youtube.com/watch?v=IYBRVRfPCK8)

## Setting Up Development Server using Docker-compose (Recommended)
## Step 1: Add environment variables
Before proceeding with any setup, you need to configure environment variables.

### Install [Docker](https://docs.docker.com/get-docker/)
### 1.Adding environment variables to .env:
- We provide a .env.example file that demonstrates how the environment is set up.

```sh
# --- Move to project directory ---
cd BLT
# --- Move to project directory ---
cd BLT

cp .env.example .env
```
- Modify the .env file as per your local setup.

## Step 2: Choose your setup method (Docker recommended)
### 1.Recommended method: Setting up development server using docker-compose

- Install docker


```sh
# --- build the docker container ---
docker-compose build

Expand All @@ -34,17 +47,15 @@

```

## Setting Up Development Server using Vagrant
### 2.Setting up development server using vagrant

### Install [Vagrant](https://www.vagrantup.com/)
-Install [vagrant](https://www.vagrantup.com/)

### Get [Virtualbox](https://www.virtualbox.org/)
-Get [virtualbox](https://www.virtualbox.org/)

### Follow the given commands
#### Follow the given commands

```sh
# Move to project directory
cd BLT

# Start vagrant - It takes time during the first run, so go get a coffee!
vagrant up
Expand All @@ -68,19 +79,19 @@
python manage.py runserver
```

### Ready to go
#### Ready to go

Then go to `http://127.0.0.1:8000/admin/socialaccount/socialapp/` and add filler information for social auth accounts.
Add a Domain `http://127.0.0.1:8000/admin/website/domain/` with the name 'owasp.org'.

### Voila go visit `http://localhost:8000`
#### Voila go visit `http://localhost:8000`

**Note:** In case you encounter an error with vagrant's vbguest module, run `vagrant plugin install vagrant-vbguest`
from the host machine.

## Setting Up Development Server using Python Virtual Environment
### 3.Setting up development server using python virtual environment

### Setup Correct python version
#### Setup correct python version

Current supported python version is `3.11.2`. It can be installed using any tool of choice like `asdf`, `pyenv`, `hatch`.
For this guide, we are using `pyenv`. Install pyenv by following instructions in its [Github Repo](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation)
Expand All @@ -92,7 +103,7 @@ pyenv install 3.11.2

Note: Project root folder already contains `.python-version`, so pyenv can recognize the local version to use for the current project.

### Setup Virtual environment using poetry
#### Setup virtual environment using poetry

Ensure that `python -V` returns the correct python version for the project

Expand Down Expand Up @@ -132,11 +143,29 @@ python manage.py collectstatic
python manage.py runserver
```

### Ready to go now
#### Ready to go now

Then go to `http://127.0.0.1:8000/admin/socialaccount/socialapp/` and add filler information for social auth accounts.
Add a Domain `http://127.0.0.1:8000/admin/website/domain/` with the name 'owasp.org'.

### Visit `http://localhost:8000`
#### Visit `http://localhost:8000`

**Note:** In case you encounter an error, run `sudo apt-get install libpq-dev`.

## Troubleshooting
If you run into issues during the setup, here are some common solutions:

### 1.Cannot install nltk, distlib, certifi
The error message you're encountering suggests that the package manager (likely poetry) is unable to find installation candidates.
Below are the temporary solutions.

```sh
poetry cache clear --all pypi

#For Docker method only
docker-compose build --no-cache
```
Feel free to contribute by solving this [issue](https://github.com/OWASP-BLT/BLT/issues/2659).

## Need more help?
If you're still facing issues or need further assistance, feel free to reach out to the community on the [OWASP Slack channel](https://owasp.org/slack/invite).
22 changes: 10 additions & 12 deletions blog/templates/blog/post_delete.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "base.html" %}

{% block content %}
<style>
<style>
body {
display: flex;
justify-content: center;
Expand Down Expand Up @@ -52,14 +51,13 @@
text-align: center;
margin: 0;
}
</style>

{% include "includes/sidenav.html" %}
<h1>Confirm Delete</h1>
<p class="post_content">Are you sure you want to delete the post "{{ post.title }}"?</p>
<form method="post" class="confirm-buttons">
{% csrf_token %}
<button type="submit" class="delete-button">Delete</button>
<a href="{% url 'post_detail' slug=post.slug %}" class="cancel-button">Cancel</a>
</form>
</style>
{% include "includes/sidenav.html" %}
<h1>Confirm Delete</h1>
<p class="post_content">Are you sure you want to delete the post "{{ post.title }}"?</p>
<form method="post" class="confirm-buttons">
{% csrf_token %}
<button type="submit" class="delete-button">Delete</button>
<a href="{% url 'post_detail' slug=post.slug %}" class="cancel-button">Cancel</a>
</form>
{% endblock content %}
46 changes: 22 additions & 24 deletions blog/templates/blog/post_details.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "base.html" %}

{% block content %}
<style>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
Expand Down Expand Up @@ -83,26 +82,25 @@
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}
</style>

{% include "includes/sidenav.html" %}
<article class="post-article">
<h1 class="post-title">{{ post.title }}</h1>
<p class="post-meta">By {{ post.author }} on {{ post.created_at }}</p>
<div class="post-content">
{{ post.content|safe }}
</div>
{% if post.image %}
<div class="post-image">
<img height="200" width="100%" src="{{ post.image.url }}" alt="{{ post.title }}">
</div>
{% endif %}

{% if request.user == post.author %}
<div class="btn-div">
<a href="{% url 'post_update' slug=post.slug %}" class="b-update">Update Post</a>
<a href="{% url 'post_delete' slug=post.slug %}" class="b-delete">Delete Post</a>
</div>
{% endif %}
</article>
</style>
{% include "includes/sidenav.html" %}
<article class="post-article">
<h1 class="post-title">{{ post.title }}</h1>
<p class="post-meta">By {{ post.author }} on {{ post.created_at }}</p>
<div class="post-content">{{ post.content|safe }}</div>
{% if post.image %}
<div class="post-image">
<img height="200"
width="100%"
src="{{ post.image.url }}"
alt="{{ post.title }}">
</div>
{% endif %}
{% if request.user == post.author %}
<div class="btn-div">
<a href="{% url 'post_update' slug=post.slug %}" class="b-update">Update Post</a>
<a href="{% url 'post_delete' slug=post.slug %}" class="b-delete">Delete Post</a>
</div>
{% endif %}
</article>
{% endblock content %}
85 changes: 42 additions & 43 deletions blog/templates/blog/post_form.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "base.html" %}

{% block content %}
<style>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
Expand Down Expand Up @@ -43,45 +42,45 @@
.form-field {
margin-bottom: 15px;
}
</style>

{% include "includes/sidenav.html" %}
<h1 id="form-title">{% if form.instance.pk %}Edit{% else %}New{% endif %} Post</h1>

<div class="form-container">
<form method="post" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<div class="form-field">
{{ form.title.label }}<br>
{{ form.title }}<br>
{% for error in form.title.errors %}
<div>{{ error }}</div>
{% endfor %}
</div>

<div class="form-field">
{{ form.content.label }}<br>
{{ form.content }}<br>
{% for error in form.content.errors %}
<div>{{ error }}</div>
{% endfor %}
</div>

<div class="form-field">
{{ form.image.label }}<br>
{{ form.image }}<br>
{% for error in form.image.errors %}
<div>{{ error }}</div>
{% endfor %}
</div>

<button type="submit">Save</button>
</form>
</div>

<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css">
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
<script>
var easyMDE = new EasyMDE({ element: document.getElementById('id_content') });
</script>
</style>
{% include "includes/sidenav.html" %}
<h1 id="form-title">
{% if form.instance.pk %}
Edit
{% else %}
New
{% endif %}
Post
</h1>
<div class="form-container">
<form method="post" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<div class="form-field">
{{ form.title.label }}
<br>
{{ form.title }}
<br>
{% for error in form.title.errors %}<div>{{ error }}</div>{% endfor %}
</div>
<div class="form-field">
{{ form.content.label }}
<br>
{{ form.content }}
<br>
{% for error in form.content.errors %}<div>{{ error }}</div>{% endfor %}
</div>
<div class="form-field">
{{ form.image.label }}
<br>
{{ form.image }}
<br>
{% for error in form.image.errors %}<div>{{ error }}</div>{% endfor %}
</div>
<button type="submit">Save</button>
</form>
</div>
<link rel="stylesheet"
href="https://unpkg.com/easymde/dist/easymde.min.css">
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
<script>var easyMDE = new EasyMDE({ element: document.getElementById('id_content') });</script>
{% endblock content %}
44 changes: 23 additions & 21 deletions blog/templates/blog/post_list.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "base.html" %}

{% block content %}
<style>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
Expand Down Expand Up @@ -60,22 +59,25 @@
border-radius: 5px;
margin-bottom: 10px;
}
</style>

{% include "includes/sidenav.html" %}
<h1 class="blog-title">Blog Posts</h1>
<ul class="post-list">
{% for post in posts %}
<a href="{% url 'post_detail' slug=post.slug %}">
<div class="post-item">
<p class="post-link">{{ post.title }} by {{ post.author }}</p>
{% if post.image %}
<img height="200" width="200" src="{{ post.image.url }}" alt="{{ post.title }}" class="blog_image">
{% endif %}
</div>
</a>
{% empty %}
<p class="no-posts-message">No posts available.</p>
{% endfor %}
</ul>
{% endblock content %}
</style>
{% include "includes/sidenav.html" %}
<h1 class="blog-title">Blog Posts</h1>
<ul class="post-list">
{% for post in posts %}
<a href="{% url 'post_detail' slug=post.slug %}">
<div class="post-item">
<p class="post-link">{{ post.title }} by {{ post.author }}</p>
{% if post.image %}
<img height="200"
width="200"
src="{{ post.image.url }}"
alt="{{ post.title }}"
class="blog_image">
{% endif %}
</div>
</a>
{% empty %}
<p class="no-posts-message">No posts available.</p>
{% endfor %}
</ul>
{% endblock content %}
Loading

0 comments on commit b82faf6

Please sign in to comment.