Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Issue Page #1377

Merged
merged 30 commits into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
92c8025
Fixed issue #168 which arose again.
mohitanand001 Jun 4, 2017
a374a38
Added migration files
mohitanand001 Jun 5, 2017
ea231d4
Add files via upload
mohitanand001 Jun 7, 2017
55db9f3
Add files via upload
mohitanand001 Jun 7, 2017
300e119
Docker/fix (#915)
AtmegaBuzz Aug 16, 2022
174e653
Alternate issue page
AtmegaBuzz Aug 6, 2023
7caf7a5
integrated basic info with backend
AtmegaBuzz Aug 8, 2023
5b4c569
suggested design changes implmented | Improved responsiveness
AtmegaBuzz Aug 11, 2023
d1e5bea
init Issue 2 page | basic layout likes, upvotes button integrated | c…
AtmegaBuzz Aug 21, 2023
b7cd037
integrated comment section with backend
AtmegaBuzz Aug 22, 2023
8a4ce79
alternate Likes, flag and comment created | Subscribe to bugs model c…
AtmegaBuzz Aug 23, 2023
5ee7e4b
Fixed issue #168 which arose again.
mohitanand001 Jun 4, 2017
cc512e1
Added migration files
mohitanand001 Jun 5, 2017
4b38718
Add files via upload
mohitanand001 Jun 7, 2017
4240470
Add files via upload
mohitanand001 Jun 7, 2017
7f455e6
Docker/fix (#915)
AtmegaBuzz Aug 16, 2022
3c29683
reinit migration, added crypto wallet address field
AtmegaBuzz Aug 23, 2023
33df520
test fixed reverted python version
AtmegaBuzz Aug 23, 2023
bf7ad25
Fixed issue #168 which arose again.
mohitanand001 Jun 4, 2017
37da3ce
Added migration files
mohitanand001 Jun 5, 2017
dfc407f
Add files via upload
mohitanand001 Jun 7, 2017
9165d79
Add files via upload
mohitanand001 Jun 7, 2017
96b4ea2
Docker/fix (#915)
AtmegaBuzz Aug 16, 2022
b75c61d
Fixed issue #168 which arose again.
mohitanand001 Jun 4, 2017
6f12eae
Added migration files
mohitanand001 Jun 5, 2017
0c7020a
Add files via upload
mohitanand001 Jun 7, 2017
f913ca0
Add files via upload
mohitanand001 Jun 7, 2017
4c997a8
Docker/fix (#915)
AtmegaBuzz Aug 16, 2022
609b621
markdown integrated | css conflict resolved
AtmegaBuzz Aug 29, 2023
a7e6ea6
revert python version
AtmegaBuzz Aug 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions blt/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@
)
from company.views import ShowBughuntView
from website.alternative_views import (
CreateHunt2,
like_issue2,
flag_issue2,
subscribe_to_domains,
IssueView2
)

from blt import settings
Expand Down Expand Up @@ -285,6 +288,17 @@
re_path(
r"^flag_issue/(?P<issue_pk>\d+)/$", website.views.flag_issue, name="flag_issue"
),

re_path(
r"^like_issue2/(?P<issue_pk>\d+)/$", like_issue2, name="like_issue2"
),
re_path(
r"^flag_issue2/(?P<issue_pk>\d+)/$", flag_issue2, name="flag_issue2"
),
path(
"domain/<int:pk>/subscribe/", subscribe_to_domains, name="subscribe_to_domains"
),

re_path(
r"^save_issue/(?P<issue_pk>\d+)/$", website.views.save_issue, name="save_issue"
),
Expand All @@ -295,7 +309,9 @@
),
re_path(r"^issue/edit/$", website.views.IssueEdit, name="edit_issue"),
re_path(r"^issue/update/$", website.views.UpdateIssue, name="update_issue"),
path("issue/<str:issue_pk>/comment/", website.views.comment_on_issue, name="comment_on_issue"),
re_path(r"^issue/(?P<slug>\w+)/$", IssueView.as_view(), name="issue_view"),
re_path(r"^issue2/(?P<slug>\w+)/$", IssueView2.as_view(), name="issue_view2"),
re_path(r"^follow/(?P<user>[^/]+)/", website.views.follow_user, name="follow_user"),
re_path(r"^all_activity/$", AllIssuesView.as_view(), name="all_activity"),
re_path(r"^label_activity/$", SpecificIssuesView.as_view(), name="all_activity"),
Expand Down Expand Up @@ -329,7 +345,6 @@
re_path(r"^accounts/", include("allauth.urls")),
re_path(r"^start/$", TemplateView.as_view(template_name="hunt.html"),name="start_hunt"),
re_path(r"^hunt/$", login_required(HuntCreate.as_view()), name="hunt"),
re_path(r"^hunt2/$", login_required(CreateHunt2.as_view()), name="hunt2"),
re_path(r"^hunts/$", ListHunts.as_view(), name="hunts"),
re_path(r"^invite/$", InviteCreate.as_view(template_name="invite.html")),
re_path(
Expand Down
24 changes: 24 additions & 0 deletions comments/migrations/0006_comment_author_fk.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.1 on 2023-08-29 04:22

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("website", "0080_alter_issue_team_members"),
("comments", "0005_auto_20170727_1309"),
]

operations = [
migrations.AddField(
model_name="comment",
name="author_fk",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="website.userprofile",
),
),
]
3 changes: 2 additions & 1 deletion comments/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db import models
from django.utils import timezone

from website.models import Issue
from website.models import Issue, UserProfile


# Create your models here.
Expand All @@ -13,6 +13,7 @@ class Comment(models.Model):
parent = models.ForeignKey('self', null=True, on_delete=models.CASCADE)
issue = models.ForeignKey(Issue, on_delete=models.CASCADE, related_name='comments')
author = models.CharField(max_length=200)
author_fk = models.ForeignKey(UserProfile,null=True,on_delete=models.SET_NULL)
author_url = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(default=timezone.now)
Expand Down
59 changes: 49 additions & 10 deletions company/static/company/js/md_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ function parse(content) {

matches.forEach(element => {
const extractedText = element.slice(1);
content = content.replace(element, '<h1>' + extractedText + '</h1>');
content = content.replace(element, '<h1 class="text-4xl font-bold">' + extractedText + '</h1>');
});
}

Expand All @@ -137,7 +137,7 @@ function parse(content) {

matches.forEach(element => {
const extractedText = element.slice(2);
content = content.replace(element, '<h2>' + extractedText + '</h2>');
content = content.replace(element, '<h2 class="text-3xl font-semibold">' + extractedText + '</h2>');
});
}

Expand All @@ -147,7 +147,7 @@ function parse(content) {

matches.forEach(element => {
const extractedText = element.slice(3);
content = content.replace(element, '<h3>' + extractedText + '</h3>');
content = content.replace(element, '<h3 class="text-2xl font-medium">' + extractedText + '</h3>');
});
}

Expand All @@ -157,7 +157,7 @@ function parse(content) {

matches.forEach(element => {
const extractedText = element.slice(2, -2);
content = content.replace(element, '<strong>' + extractedText + '</strong>');
content = content.replace(element, '<strong class="font-bold">' + extractedText + '</strong>');
});
}

Expand All @@ -167,7 +167,7 @@ function parse(content) {

matches.forEach(element => {
const extractedText = element.slice(2, -1);
content = content.replace(element, ' <em>' + extractedText + '</em>');
content = content.replace(element, ' <em class="italic">' + extractedText + '</em>');
});
}

Expand All @@ -179,7 +179,7 @@ function parse(content) {
const text = element.match(/^\[.*\]/)[0].slice(1, -1);
const url = element.match(/\]\(.*\)/)[0].slice(2, -1);

content = content.replace(element, '<a href="' + url + '">' + text + '</a>');
content = content.replace(element, '<a class="text-blue-500 underline" href="' + url + '">' + text + '</a>');
});
}

Expand All @@ -194,7 +194,7 @@ function parse(content) {
currentValue = '<li>' + currentValue.slice(2) + '</li>';

if (!unorderedList.test(array[index - 1]) && !unorderedSubList.test(array[index - 1])) {
currentValue = '<ul>' + currentValue;
currentValue = '<ul class="list-disc pl-4">' + currentValue;
}

if (!unorderedList.test(array[index + 1]) && !unorderedSubList.test(array[index + 1])) {
Expand Down Expand Up @@ -227,7 +227,7 @@ function parse(content) {
currentValue = '<li>' + currentValue.slice(2) + '</li>';

if (!orderedList.test(array[index - 1]) && !orderedSubList.test(array[index - 1])) {
currentValue = '<ol>' + currentValue;
currentValue = '<ol class="list-decimal pl-4">' + currentValue;
}

if (!orderedList.test(array[index + 1]) && !orderedSubList.test(array[index + 1]) && !orderedList.test(array[index + 1])) {
Expand All @@ -244,15 +244,15 @@ function parse(content) {
currentValue = '<li>' + currentValue.slice(2) + '</li>';

if (!orderedSubList.test(array[index - 1])) {
currentValue = '<ol>' + currentValue;
currentValue = '<ol class="list-decimal pl-4">' + currentValue;
}

if (orderedList.test(array[index + 1]) && !orderedSubList.test(array[index + 1])) {
currentValue = currentValue + '</ol>';
}

if (!orderedList.test(array[index + 1]) && !orderedSubList.test(array[index + 1])) {
currentValue = currentValue + '</ol></li></ol>';
currentValue = currentValue + '</ol class="list-decimal pl-4"></li></ol>';
}
}

Expand All @@ -270,3 +270,42 @@ function parse(content) {
}
}).join('');
}


function parse2(content) {
// Regular Expressions
const h1 = /^#{1}[^#].*$/gm;
const h2 = /^#{2}[^#].*$/gm;
const h3 = /^#{3}[^#].*$/gm;
const bold = /\*\*[^\*\n]+\*\*/gm;
const italics = /[^\*]\*[^\*\n]+\*/gm;
const link = /\[[\w|\(|\)|\s|\*|\?|\-|\.|\,]*(\]\(){1}[^\)]*\)/gm;
const lists = /^((\s*((\*|\-)|\d(\.|\))) [^\n]+))+$/gm;
const unorderedList = /^[\*|\+|\-]\s.*$/;
const unorderedSubList = /^\s\s\s*[\*|\+|\-]\s.*$/;
const orderedList = /^\d\.\s.*$/;
const orderedSubList = /^\s\s+\d\.\s.*$/;

// ... (your existing parsing logic)

// Apply consistent Tailwind CSS classes to generated HTML elements
content = content.replace(h1, '<h1 class="text-4xl font-bold">$1</h1>');
content = content.replace(h2, '<h2 class="text-3xl font-semibold">$1</h2>');
content = content.replace(h3, '<h3 class="text-2xl font-medium">$1</h3>');
content = content.replace(bold, '<strong class="font-bold">$1</strong>');
content = content.replace(italics, '<em class="italic">$1</em>');
content = content.replace(link, '<a class="text-blue-500 underline" href="$1">$2</a>');
// ... (update the rest of the parsing logic)

// Apply Tailwind CSS classes to lists and list items
content = content.replace(unorderedList, '<ul class="list-disc pl-4">$&');
content = content.replace(unorderedSubList, '<ul class="list-disc pl-8">$&');
content = content.replace(orderedList, '<ol class="list-decimal pl-4">$&');
content = content.replace(orderedSubList, '<ol class="list-decimal pl-8">$&');
content = content.replace('</li>', '</li>'); // Ensure list item closing tag

// Apply Tailwind CSS class to paragraphs
content = content.replace(/<p>(.*?)<\/p>/g, '<p class="text-base">$1</p>');

return '<div class="container mx-auto py-8">' + content + '</div>';
}
Loading