Added in feeds django app, can be manged in the admin backend
This commit is contained in:
parent
7e200cf71f
commit
3311080fde
31
README.org
31
README.org
|
@ -1,6 +1,20 @@
|
|||
* Maidstone hackspace website
|
||||
|
||||
Repository for the maidstone hackspace website
|
||||
|
||||
|
||||
First build your containers locally if needed, only needed when you first start or if requirements change.
|
||||
** Requirements
|
||||
Before getting started make sure you have compose and docker and git installed on your machine
|
||||
The simplest way to setup this site is to use docker-compose so please install that from this site https://docs.docker.com/engine/installation/ and make sure the quick start guide works https://docs.docker.com/machine/get-started/ then you can use the commands below to test and make changes.
|
||||
|
||||
** Setup
|
||||
To get started checkout the project to your machine.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
git clone https://github.com/olymk2/maidstone-hackspace.git
|
||||
#+END_SRC
|
||||
|
||||
Once checked out build your containers locally if needed, only needed when you first start or if requirements change.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -fdev.yml build
|
||||
|
@ -11,3 +25,18 @@ Startup your new containers containing a database and django
|
|||
#+BEGIN_SRC sh
|
||||
docker-compose -fdev up
|
||||
#+END_SRC
|
||||
|
||||
Test django is serving pages
|
||||
http://127.0.0.1:8180
|
||||
|
||||
|
||||
Run migrations and setup admin user
|
||||
to run django command just prefix them with =docker-compose -f dev.yml run django=
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -f dev.yml run django python manage.py makemigrations
|
||||
docker-compose -f dev.yml run django python manage.py migrate
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -f dev.yml run django python manage.py createsuperuser
|
||||
#+END_SRC
|
||||
|
|
|
@ -46,6 +46,7 @@ THIRD_PARTY_APPS = (
|
|||
LOCAL_APPS = (
|
||||
# custom users app
|
||||
'mhackspace.users.apps.UsersConfig',
|
||||
'mhackspace.feeds',
|
||||
# Your stuff: custom apps go here
|
||||
)
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ CACHES = {
|
|||
MIDDLEWARE += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
INSTALLED_APPS += ('debug_toolbar', )
|
||||
|
||||
ALLOWED_HOSTS = ['*']
|
||||
INTERNAL_IPS = ['127.0.0.1', '10.0.2.2', ]
|
||||
# tricks to have debug toolbar when developing with docker
|
||||
if os.environ.get('USE_DOCKER') == 'yes':
|
||||
|
|
9
dev.yml
9
dev.yml
|
@ -26,18 +26,13 @@ services:
|
|||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
- "8000:8000"
|
||||
- "8180:8000"
|
||||
links:
|
||||
- postgres
|
||||
|
||||
- mailhog
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog
|
||||
ports:
|
||||
- "8025:8025"
|
||||
- "8025:8125"
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ services:
|
|||
build: ./compose/nginx
|
||||
depends_on:
|
||||
- django
|
||||
|
||||
- certbot
|
||||
|
||||
ports:
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
* Maidstone hackspace website
|
||||
|
||||
Repository for the maidstone hackspace website
|
||||
|
||||
|
||||
** Requirements
|
||||
Before getting started make sure you have compose and docker and git installed on your machine
|
||||
The simplest way to setup this site is to use docker-compose so please install that from this site https://docs.docker.com/engine/installation/ and make sure the quick start guide works https://docs.docker.com/machine/get-started/ then you can use the commands below to test and make changes.
|
||||
|
||||
** Setup
|
||||
To get started checkout the project to your machine.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
git clone https://github.com/olymk2/maidstone-hackspace.git
|
||||
#+END_SRC
|
||||
|
||||
Once checked out build your containers locally if needed, only needed when you first start or if requirements change.
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -fdev.yml build
|
||||
#+END_SRC
|
||||
|
||||
Startup your new containers containing a database and django
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -fdev up
|
||||
#+END_SRC
|
||||
|
||||
Test django is serving pages
|
||||
http://127.0.0.1:8180
|
||||
|
||||
|
||||
Run migrations and setup admin user
|
||||
to run django command just prefix them with =docker-compose -f dev.yml run django=
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -f dev.yml run django python manage.py makemigrations
|
||||
docker-compose -f dev.yml run django python manage.py migrate
|
||||
#+END_SRC
|
||||
|
||||
#+BEGIN_SRC sh
|
||||
docker-compose -f dev.yml run django python manage.py createsuperuser
|
||||
#+END_SRC
|
|
@ -0,0 +1,12 @@
|
|||
from django.contrib import admin
|
||||
from django.contrib.admin import AdminSite, TabularInline, ModelAdmin
|
||||
from mhackspace.feeds.models import Feed
|
||||
|
||||
|
||||
@admin.register(Feed)
|
||||
class FeedAdmin(ModelAdmin):
|
||||
list_display = ('url', 'author', 'tags', 'enabled')
|
||||
|
||||
admin.site.site_title = 'Maidstone hackspace Admin Area'
|
||||
admin.site.site_header = 'Maidstone hackspace Admin Area'
|
||||
admin.site.index_title = 'Maidstone Admin Home'
|
|
@ -0,0 +1,4 @@
|
|||
Postgres is up - continuing...
|
||||
/usr/local/lib/python3.5/site-packages/environ/environ.py:608: UserWarning: /app/config/settings/.env doesn't exist - if you're not configuring your environment separately, create one.
|
||||
"environment separately, create one." % env_file)
|
||||
[{"model": "feeds.feed", "pk": 1, "fields": {"url": "http://waistcoatforensicator.blogspot.com/feeds/posts/default?alt=rss", "author": "Simon Ridley", "tags": "", "image": "", "enabled": true}}, {"model": "feeds.feed", "pk": 2, "fields": {"url": "http://www.matthewbeddow.co.uk/?feed=rss2", "author": "Mathew Beddow", "tags": "tech", "image": "", "enabled": true}}, {"model": "feeds.feed", "pk": 3, "fields": {"url": "http://blog.digitaloctave.co.uk/rss.xml", "author": "Oliver Marks", "tags": "", "image": "", "enabled": true}}, {"model": "feeds.feed", "pk": 4, "fields": {"url": "http://webboggles.com/feed/", "author": "Ilya Titov", "tags": "", "image": "", "enabled": true}}, {"model": "feeds.feed", "pk": 5, "fields": {"url": "http://thearduinoguy.org/?feed=rss2", "author": "Mike McRoberts", "tags": "", "image": "", "enabled": true}}, {"model": "feeds.feed", "pk": 6, "fields": {"url": "https://feeds.feedburner.com/projects-jl", "author": "James", "tags": "", "image": "", "enabled": false}}]
|
|
@ -0,0 +1,18 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django import template
|
||||
from mhackspace.feeds.models import Feed
|
||||
from scaffold.readers.rss_reader import feed_reader
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.inclusion_tag('feed_tiles.html')
|
||||
def fetch_feeds():
|
||||
for feed
|
||||
rss_feeds = []
|
||||
for feed in Feed.objects.all():
|
||||
rss_feeds.append({
|
||||
'author':'Simon Ridley',
|
||||
'url': 'http://waistcoatforensicator.blogspot.com/feeds/posts/default?alt=rss'
|
||||
})
|
||||
|
||||
return feed_reader(rss_feeds)
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.4 on 2017-01-04 14:04
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Feed',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('url', models.CharField(max_length=255)),
|
||||
('author', models.CharField(max_length=255)),
|
||||
('tags', models.CharField(max_length=255)),
|
||||
('image', models.ImageField(upload_to='')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -0,0 +1,30 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.4 on 2017-01-04 20:33
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('feeds', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='feed',
|
||||
name='id',
|
||||
field=models.IntegerField(primary_key=True, serialize=False),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='feed',
|
||||
name='image',
|
||||
field=models.ImageField(blank=True, upload_to=''),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='feed',
|
||||
name='tags',
|
||||
field=models.CharField(blank=True, max_length=255),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.4 on 2017-01-04 20:35
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('feeds', '0002_auto_20170104_2033'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='feed',
|
||||
name='id',
|
||||
field=models.AutoField(primary_key=True, serialize=False),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.10.4 on 2017-01-04 21:39
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('feeds', '0003_auto_20170104_2035'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='feed',
|
||||
name='enabled',
|
||||
field=models.BooleanField(default=True),
|
||||
),
|
||||
]
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals, absolute_import
|
||||
|
||||
from django.db import models
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
|
||||
@python_2_unicode_compatible
|
||||
class Feed(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
url = models.CharField(max_length=255)
|
||||
author = models.CharField(max_length=255)
|
||||
tags = models.CharField(max_length=255, blank=True)
|
||||
image = models.ImageField(blank=True)
|
||||
enabled = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.url
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from django import template
|
||||
from mhackspace.feeds.models import Feed
|
||||
from scaffold.readers.rss_reader import feed_reader
|
||||
|
||||
register = template.Library()
|
||||
|
||||
@register.inclusion_tag('feeds/list.html')
|
||||
def show_feeds():
|
||||
rss_feeds = []
|
||||
for feed in Feed.objects.all():
|
||||
if feed.enabled is False:
|
||||
continue
|
||||
rss_feeds.append({
|
||||
'author': feed.author,
|
||||
'url': feed.url
|
||||
})
|
||||
|
||||
result = feed_reader(rss_feeds)
|
||||
return {'feeds': [item for item in result]}
|
|
@ -42,6 +42,21 @@
|
|||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Chat</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Donate</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Contat</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Mailing List</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'home' %}">Login</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'about' %}">About</a>
|
||||
</li>
|
||||
|
@ -82,7 +97,25 @@
|
|||
{% endblock content %}
|
||||
|
||||
</div> <!-- /container -->
|
||||
|
||||
<footer class="footer">
|
||||
<div class="m-b-1 navbar-dark bg-inverse"> </div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div mailing-list-signup="" class="google-groups-signup">
|
||||
<h3>Signup and make yourself known</h3>
|
||||
<form class="block" name="signup" method="get" action="https://groups.google.com/group/maidstone-hackspace/boxsubscribe">
|
||||
<label for="groups-email">Email Address</label>
|
||||
<input id="groups-email" name="email" class="required">
|
||||
<button type="submit">Subscribe</button>
|
||||
<a href="http://groups.google.com/group/maidstone-hackspace">View Group</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">©2016 Maidstone Hackspace</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
{% block modal %}{% endblock modal %}
|
||||
|
||||
<!-- Le javascript
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
Maker feed
|
||||
|
||||
<div class="card-deck-wrapper">
|
||||
<div class="card-deck">
|
||||
{% for feed in feeds %}
|
||||
<div class="card">
|
||||
<img class="card-img-top img-responsive" src="{{ feed.image }}" alt="Card image cap" style="width:100%">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">{{ feed.title }}</h4>
|
||||
<p class="card-text">{{ feed.author }}</p>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<p class="card-text">{{ feed.description }}</p>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<a href="{{ feed.url }}" class="card-link">View Original</a>
|
||||
</div>
|
||||
</div>
|
||||
{% if forloop.counter|divisibleby:3 %}</div><div class="card-deck">{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
|
@ -1 +1,8 @@
|
|||
{% extends "base.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load feed_views %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Introduction</h2>
|
||||
Hackspaces are a shared space where artists, designers, makers, hackers, programmers, tinkerers, professionals and hobbyists can work on their projects, share knowledge and collaborate.We are in the process of developing Maidstone Hackspace. We're previous members of (ICMP) and looking to form a new space in the future. At the moment, communication is via google groups, email, and the website. If you're at all intrested please join our mailing list and make yourself known!
|
||||
{% show_feeds %}
|
||||
{% endblock content %}
|
||||
|
|
|
@ -46,5 +46,7 @@ redis>=2.10.5
|
|||
rcssmin==1.0.6
|
||||
django-compressor==2.1
|
||||
|
||||
lxml
|
||||
|
||||
# Your custom requirements go here
|
||||
-e git+https://github.com/olymk2/scaffold.git#egg=scaffold
|
||||
|
|
Loading…
Reference in New Issue