created spectrum

This commit is contained in:
Rushil Umaretiya 2020-08-16 10:40:55 -04:00
parent 5c337b3807
commit 62596201ad
15 changed files with 97 additions and 3 deletions

View File

@ -78,6 +78,7 @@ SOCIAL_AUTH_STORAGE = 'social_django.models.DjangoStorage'
INSTALLED_APPS = [
'news.apps.NewsConfig',
'users.apps.UsersConfig',
'spectrum.apps.SpectrumConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',

View File

@ -25,6 +25,7 @@ from users import views as user_views
urlpatterns = [
path('', include('news.urls')),
path('spectrum/', include('spectrum.urls')),
path('admin/', admin.site.urls),

View File

@ -22,8 +22,8 @@ ul {
background: #0F2027; /* fallback for old browsers */
/*background: -webkit-linear-gradient(to right, #2C5364, #203A43, #0F2027); */ /* Chrome 10-25, Safari 5.1-6 */
/*background: linear-gradient(to right, #2C5364, #203A43, #0F2027); */ /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
background: -webkit-linear-gradient(to right, #E42D2D, #2460E9);
background: linear-gradient(to right, #E42D2D, #2460E9);
background: -webkit-linear-gradient(to left, #E42D2D, #2460E9);
background: linear-gradient(to left, #E42D2D, #2460E9);
/* border-bottom: 3px #111 solid; */
}
@ -164,5 +164,14 @@ a.article-title:hover {
}
}
.left {
color: #2460E9!important;
}
.center {
color: #84478B!important;
}
.right {
color: #E42D2D!important;
}

View File

@ -40,6 +40,7 @@
<!-- Navbar Right Side -->
<div class="navbar-nav">
{% if user.is_authenticated %}
<a class="nav-item nav-link" href="{% url 'spectrum' %}">Spectrum</a>
<a class="nav-item nav-link" href="{% url 'article-create' %}">Write</a>
<a class="nav-item nav-link" href="{% url 'profile' %}">
<!-- <img class="rounded-circle account-img" src="{{ user.profile.profile_pic.url }}"> -->{{ user.username }}

View File

@ -2,7 +2,7 @@
{% block content %}
<div class="row">
{% for article in articles %}
{% for article in feed %}
<div class="col-lg-4 col-sm-6 mb-4" style="margin-top: 2%">
<div class="card shadow border-0 h-100"><a href="">
<img src="{{ article.header.url }}" alt="..." class="img-fluid card-img-top"></a>

0
spectrum/__init__.py Normal file
View File

3
spectrum/admin.py Normal file
View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
spectrum/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class SpectrumConfig(AppConfig):
name = 'spectrum'

View File

3
spectrum/models.py Normal file
View File

@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

View File

@ -0,0 +1,21 @@
{% extends 'news/base.html' %}
{% block content %}
<div class="row">
{% for article in feed %}
<div class="col-lg-4 col-sm-6 mb-4" style="margin-top: 2%">
<div class="card shadow border-0 h-100"><a href="">
<div class="card-body">
<h5 class="my-2"><a href="{{article.link}}" class="nounderline text-dark">{{ article.title }}</a></h5>
<p>By: {{ article.author }}</p>
<p class="my-2 text-muted text-sm">{{article.summary|safe|truncatechars_html:200|linebreaks }}</p>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:3 %}
</div><!-- close existing row and open another one-->
<div class="row">
{% endif %}
{% endfor %}
</div>
{% endblock content %}

View File

@ -0,0 +1,16 @@
{% extends 'news/base.html' %}
{% block content %}
<div class="media-content pt-5">
<div class="row">
<div class="col">
<h1><a class="left nounderline" href="{% url 'spectrum-left' %}">Left</a></h1>
</div>
<div class="col">
<h1><a class="center nounderline" href="{% url 'spectrum-center' %}">Center</a></h1>
</div>
<div class="col">
<h1><a class="right nounderline" href="{% url 'spectrum-right' %}">Right</a></h1>
</div>
</div>
</div>
{% endblock content %}

3
spectrum/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
spectrum/urls.py Normal file
View File

@ -0,0 +1,9 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.spectrum, name='spectrum'),
path('left/', views.left, name='spectrum-left'),
path('center/', views.center, name='spectrum-center'),
path('right/', views.right, name='spectrum-right'),
]

22
spectrum/views.py Normal file
View File

@ -0,0 +1,22 @@
from django.shortcuts import render
import feedparser
# Create your views here.
def spectrum(request):
return render(request, "spectrum/home.html")
def right(request):
feed = feedparser.parse("http://feeds.foxnews.com/foxnews/politics")
print(feed.entries)
context = {
"feed": feed.entries
}
return render (request, "spectrum/feed.html", context)
def left(request):
pass
def center(request):
pass