Skip to content

Commit

Permalink
Remove infinite merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeMaxx authored and System Administrator committed May 7, 2016
2 parents 427a6e9 + 2793e89 commit 0fece25
Show file tree
Hide file tree
Showing 28 changed files with 644 additions and 55 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ Temporary Items

*.iml

## Directory-based project format:
../.idea/

## File-based project format:
*.ipr
*.iws
Expand Down
16 changes: 16 additions & 0 deletions docupload/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.contrib import admin

# Register your models here.
from .models import Documentation


class DocumentationAdmin(admin.ModelAdmin):
list_display = ["name", "pub_date"]
list_display_links = ["name"]
list_filter = ["pub_date"]
search_fields = ["name"]
class Meta:
model = Documentation


admin.site.register(Documentation, DocumentationAdmin)
16 changes: 12 additions & 4 deletions docupload/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
from django import forms

from .models import Documentation

class DocUploadForm(forms.Form):
'''Form for documentation file upload'''

name = forms.CharField(max_length=100)
doc_file = forms.FileField()
class DocUploadForm(forms.ModelForm):
'''Form for documentation file upload'''
class Meta(object):
model = Documentation
fields = [
"name",
"doc_file",
]
widgets = {
'name': forms.TextInput(attrs={'placeholder': 'Enter Title','class': 'form-control'}),
}
1 change: 1 addition & 0 deletions docupload/htmlify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'''

import os

import pypandoc


Expand Down
20 changes: 20 additions & 0 deletions docupload/migrations/0002_auto_20160505_0834.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-05-05 03:04
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('docupload', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='documentation',
name='doc_file',
field=models.FileField(upload_to='/home/darknight/Desktop/oksp/media/'),
),
]
7 changes: 6 additions & 1 deletion docupload/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.conf import settings
from django.db import models

class Documentation(models.Model):
Expand All @@ -6,5 +7,9 @@ class Documentation(models.Model):
'''

name = models.CharField(max_length=200)
doc_file = models.FilePathField('../static/docs/')
#doc_file = models.FilePathField('../static/docs/')
doc_file = models.FileField(upload_to = '%s/media/' %settings.BASE_DIR)
pub_date = models.DateTimeField('date published')

def __str__(self):
return self.name
40 changes: 40 additions & 0 deletions docupload/templates/docupload/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% load staticfiles %}
<!DOCTYPE html>
<html>
<head>
<title>{% block head_title %}OKSP{% endblock head_title %}</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href='{% static "css/base.css" %}' />
{% block csslink %}

{% endblock csslink %}
{% block jslink %}

{% endblock jslink %}
<style>
.container-fluid .navbar .navbar-brand {
color: white;
}
{% block style %}
{% endblock style %}
</style>
</head>
<body>
<div class="container-fluid" style="margin: 0; padding: 0">
{% block bar %}

{% endblock bar %}
</div>
<div class="container-fluid" style="margin: 0; padding: 0">
{% block content %}

{% endblock content %}
</div>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>
24 changes: 24 additions & 0 deletions docupload/templates/docupload/editor_choice.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% extends "docupload/base.html" %}

{% block style %}
body {
background:black;
}
{% endblock style %}

{% block bar %}
<div class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin: 0; padding: 0">
<a class="navbar-brand" rel="home" href='#' title="OKSP">OKSP</a>
</div>
{% endblock bar %}

{% block content %}
<div class="jumbotron text-center" style="background: black;">
<div class="container">
<h1 style="color:white;">OKSP Editor</h1>
<p style="color:white">Welcome to the documentation upload portal.<br/>Please choose the editor of your choice. We support Markdown as well as WYSIWYG (eg MS Word, Google Docs)</p>
<span style="margin-right: 2em;"><a class="btn btn-info btn-lg" href="{% url 'docupload:markdown_editor' %}" role="button">Markdown &raquo;</a></span>
<span style="margin-left: 2em;"><a class="btn btn-info btn-lg" href="{% url 'docupload:wsyiwyg_editor' %}" role="button">WYSIWYG &raquo;</a></span>
</div>
</div>
{% endblock content %}
71 changes: 56 additions & 15 deletions docupload/templates/docupload/index.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,56 @@
<form name="docupload" action="{% url 'docupload:upload' %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
<input type="submit" value="Submit">
</form>
<hr><br>
{% if doc_list %}
<ul>
{% for doc in doc_list %}
<li><a href="/doc/{{ doc.id }}/">{{ doc.name }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>No docs are available.</p>
{% endif %}
{% extends "docupload/base.html" %}

{% block style %}
body {
background: black;
}
.form-group, h3 {
color: white;
}
{% endblock style %}

{% block bar %}
<div class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin: 0; padding: 0">
<a class="navbar-brand" rel="home" href='#' title="OKSP">OKSP</a>
</div>
{% endblock bar %}

{% block content %}
<div class="container-fluid" style="margin: 0; padding: 0;">
<div class="jumbotron" style="background: black;">
<h3 style="text-align: center;">Fill out the Details</h3>
<form method='POST' action="{% url 'docupload:upload' %}" enctype="multipart/form-data" role="form">{% csrf_token %}
<div class="form-group">
<label>Title:</label>
{{ form.name }}
</div>
<div class="form-group">
<label>File:</label>
{{ form.doc_file }}
</div>
<input type = 'submit' class = 'btn btn-primary' value='Submit' />
</form>
<hr/>
<div class="container">
<div class="row">
{% if doc_list %}
{% for doc in doc_list %}
<div class="col-sm-6" style="margin: 0; padding: 0;">
<div class="thumbnail">
<!--<img src="..." alt="...">-->
<div class="caption">
<h3><a href='/doc/{{ doc.id }}/'>{{ doc.name }}<small> {{ doc.pub_date|timesince }} ago</small> </a></h3>
</div>
</div>
</div>

{% cycle "" "<div class = 'col-sm-12'><hr/></div></div><div class='row'>" %}
{% endfor %}
{% else %}
<h3>No docs are available.</h3>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock content %}
47 changes: 47 additions & 0 deletions docupload/templates/docupload/markdown.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "docupload/base.html" %}

{% block jslink %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/showdown/1.3.0/showdown.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
{% endblock jslink %}

{% block style %}
.well {
background: white;
}
body {
background: black;
}
{% endblock style %}

{% block bar %}
<div class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin: 0; padding: 0">
<a class="navbar-brand" rel="home" href='#' title="OKSP">OKSP</a>
</div>
{% endblock bar %}

{% block content %}
<div class="jumbotron" style="background: black;">
<div class="container">
<h1 style="text-align: center; color: white;">Markdown Editor</h1>
</div>
<textarea id="sourceTA" rows="25" style="width: 49%; display: inline-block;" class="well" placeholder="Start writing here"></textarea>
<div id='targetDiv' style="float: right; width: 49%; overflow: scroll; height: 38.5em;" class="well"></div>
<hr/>
<script>
function run() {
var text = document.getElementById('sourceTA').value,
target = document.getElementById('targetDiv'),
converter = new showdown.Converter(),
html = converter.makeHtml(text);

target.innerHTML = html;
}

$('#sourceTA').on('change keyup paste', function() {
run();
console.log(this.value);
});
</script>
</div>
{% endblock content %}
33 changes: 33 additions & 0 deletions docupload/templates/docupload/wsyiwyg.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{% extends "docupload/base.html" %}

{% block style %}
body {
background: black;
}
{% endblock style %}

{% block jslink %}
<script src="//cdn.ckeditor.com/4.5.8/full/ckeditor.js"></script>
{% endblock jslink %}


{% block bar %}
<div class="navbar navbar-inverse navbar-static-top" role="navigation" style="margin: 0; padding: 0">
<a class="navbar-brand" rel="home" href='#' title="OKSP">OKSP</a>
</div>
{% endblock bar %}

{% block content %}
<div class="jumbotron" style="background: black;">
<h1 style="text-align: center; color: white;">WSYIWYG Editor</h1>
<hr/>
<textarea name="editor1"></textarea>
<script>
CKEDITOR.replace( 'editor1' );
CKEDITOR.config.width = '100%';
CKEDITOR.config.height = 500;
</script>
<hr/>
</div>

{% endblock content %}
3 changes: 3 additions & 0 deletions docupload/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^upload/$', views.upload, name='upload'),
url(r'^editor_choice/$', views.editor_choice, name='editor_choice'),
url(r'^editor_choice/markdown$', views.markdown_editor, name='markdown_editor'),
url(r'^editor_choice/wsyiwyg$', views.wsyiwyg_editor, name='wsyiwyg_editor'),
url(r'^(?P<doc_id>\d+)/$', views.display, name='upload'),
]
19 changes: 13 additions & 6 deletions docupload/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

from datetime import datetime

from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from django.template import loader

from .forms import DocUploadForm
Expand All @@ -23,16 +23,24 @@ def index(request):
'doc_list': doc_list,
'form': form,
}
return HttpResponse(template.render(context, request))
return render(request,"docupload/index.html", context)

def editor_choice(request):
return render(request, "docupload/editor_choice.html")

def markdown_editor(request):
return render(request, "docupload/markdown.html")

def upload(request):
def wsyiwyg_editor(request):
return render(request, "docupload/wsyiwyg.html")

def upload(request):
'''View for /doc/upload/'''

html = HTMLifier(doc_base_path=DOC_DIR)

if request.method == 'POST':
form = DocUploadForm(request.POST, request.FILES)
form = DocUploadForm(request.POST or None, request.FILES or None)
if form.is_valid():
filename = html.convert(request.FILES['doc_file'])
doc = Documentation(name=request.POST['name'],
Expand All @@ -47,6 +55,5 @@ def display(request, doc_id):

db_doc = Documentation.objects.filter(id=doc_id)[0]

with open('docupload/docs/' + db_doc.doc_file) as doc:
with open('docupload/docs/' + str(db_doc.doc_file)) as doc:
return HttpResponse(doc)

21 changes: 20 additions & 1 deletion hacker_news/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
from django.contrib import admin

# Register your models here.
from .models import New, comment


class NewsAdmin(admin.ModelAdmin):
list_display = ['title']
list_display_links = ['title']
search_fields = ['title']
class Meta:
model = New

class CommentsAdmin(admin.ModelAdmin):
list_display = ['text']
list_display_links = ['text']
search_fields = ['text']
class Meta:
model = comment


admin.site.register(New, NewsAdmin)
admin.site.register(comment, CommentsAdmin)
Loading

0 comments on commit 0fece25

Please sign in to comment.