Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion cosmos
Submodule cosmos updated from 2006c2 to 865220
4 changes: 2 additions & 2 deletions cosmos_search/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
# Application definition

INSTALLED_APPS = [
'update.apps.UpdateConfig',
'search.apps.SearchConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'update.apps.UpdateConfig',
'search.apps.SearchConfig',
]

MIDDLEWARE = [
Expand Down
8 changes: 6 additions & 2 deletions search/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
from django.contrib import admin # noqa
from django.contrib import admin

# Register your models here.
from search.models import Votes
from search.models import Comment

admin.site.register(Votes)
admin.site.register(Comment)
45 changes: 45 additions & 0 deletions search/form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django import forms
from .models import Votes
from .models import Comment


VOTES_CHOICES = [
('1', ''),
('2', ''),
['3', ''],
('4', ''),
('5', ''),
]


class VotesForm(forms.Form):
project_name = forms.CharField(max_length=500, required=False)
ip_address = forms.CharField(max_length=50, required=False)
vote_value = forms.ChoiceField(VOTES_CHOICES, required=True,
widget=forms.RadioSelect(attrs={"onclick": "this.form.submit();",
"class": "votes",
"data-fa-icon": "&#xf005"}))

def save(self):
u = Votes.objects.create(
project_name=self.cleaned_data['project_name'],
vote_value=self.cleaned_data['vote_value'],
ip_address=self.cleaned_data['ip_address'],
)
u.save()
return u


class CommentForm(forms.Form):
project_name = forms.CharField(max_length=500, required=False)
ip_address = forms.CharField(max_length=50, required=False)
comment = forms.CharField(max_length=500, required=False)

def save(self):
u = Comment.objects.create(
project_name=self.cleaned_data['project_name'],
comment=self.cleaned_data['comment'],
ip_address=self.cleaned_data['ip_address'],
)
u.save()
return u
28 changes: 26 additions & 2 deletions search/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
from django.db import models # noqa
from django.db import models

# Create your models here.
VOTES_CHOICES = [
('1', '1'),
('2', '2'),
('3', '3'),
('4', '4'),
('5', '5'),
]


class Votes(models.Model):
project_name = models.CharField(max_length=500, null=True, blank=True)
vote_value = models.CharField(choices=VOTES_CHOICES, default='1', max_length=20, null=True)
ip_address = models.CharField(max_length=50, null=True, blank=True)

def __str__(self):
return self.vote_value


class Comment (models.Model):
project_name = models.CharField(max_length=500, null=True, blank=True)
comment = models.CharField(max_length=500, null=True, blank=True)
ip_address = models.CharField(max_length=50, null=True, blank=True)

def __str__(self):
return self.comment
193 changes: 144 additions & 49 deletions search/templates/cosmos/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css"
media="all"/>

<style>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.8.18/themes/base/jquery-ui.css" type="text/css" media="all" />
<style>
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css");
html {
position: relative;
min-height: 100%;
Expand All @@ -34,16 +33,17 @@
display: block;
text-align: left;
width: 80%;
padding-top: 20px;
padding-bottom: 20px;
padding-top: 15%;
padding-bottom: 15%;
margin: 0 auto;
}

.footer {
position: absolute;
bottom: 0;
width: 100%;
padding: 1em;
height: 60px;
line-height: 60px;
background-color: #f5f5f5;
}

Expand All @@ -52,7 +52,51 @@
line-height: 1.2 !important;
}

.stylish-input-group .input-group-addon {
#id_vote_value {
display: flex;
padding: 0%;
list-style-type: none;
}
#id_vote_value::after {
content: '';
}

#id_vote_value li {
padding-left: 1%;
}

.votes {
-webkit-appearance: none;
-moz-appearance: none;
-o-appearance: none;
-ms-appearance: none;
appearance: none;
outline: none !important;
}

.votes:after {
font-family: 'FontAwesome';
display: inline-block;
text-align: center;
font-size: 20px;
content: "\f005";
padding: 2 10px;
border-radius: 15px;
color: rgba(0, 0, 0, 0.4);
-webkit-transition: color 1s, -webkit-box-shadow 1s;
transition: color 1s, -webkit-box-shadow 1s;
transition: box-shadow 1s, color 1s;
transition: box-shadow 1s, color 1s, -webkit-box-shadow 1s;

}

.votes:checked:after {
-webkit-box-shadow: 2px 2px 14px rgba(0, 0, 0, 0.4);
box-shadow: 2px 2px 14px rgba(0, 0, 0, 0.4);
color: rgba(255, 255, 255, 0.6);
}

.stylish-input-group .input-group-addon{
background: white !important;
}

Expand All @@ -76,49 +120,100 @@
{% block style %}
{% endblock %}

<script type="text/javascript">
function getUserIP(onNewIP) { // onNewIp - your listener function for new IPs
//compatibility for firefox and chrome
var myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
var pc = new myPeerConnection({
iceServers: []
}),
noop = function () {
},
localIPs = {},
ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g,
key;

function iterateIP(ip) {
if (!localIPs[ip]) onNewIP(ip);
localIPs[ip] = true;
}

//create a bogus data channel
pc.createDataChannel("");

// create offer and set local description
pc.createOffer(function (sdp) {
sdp.sdp.split('\n').forEach(function (line) {
if (line.indexOf('candidate') < 0) return;
line.match(ipRegex).forEach(iterateIP);
});

pc.setLocalDescription(sdp, noop, noop);
}, noop);

//listen for candidate events
pc.onicecandidate = function (ice) {
if (!ice || !ice.candidate || !ice.candidate.candidate || !ice.candidate.candidate.match(ipRegex)) return;
ice.candidate.candidate.match(ipRegex).forEach(iterateIP);
};
}

// Usage

getUserIP(function (ip) {
var value = ip;
document.getElementById('ip').value = value;
});
</script>
<script>
function getVote(int) {
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
</script>
</head>

<body style="overflow-x: hidden;">
<div class="container">
<br>
<div class="row">
<div class="col-4">
<a class="navbar-brand" href="/">cosmos-search</a>
</div>
<div class="col-8">
<a class="btn float-right" href="https://github.com/OpenGenus/cosmos-search">GitHub</a>
<a class="btn float-right" href="https://github.com/OpenGenus/cosmos">cosmos</a>
<a class="btn float-right" href="{% url 'calculator' %}">calculator</a>
</div>
</div>
</br>
<div class="row">
{# align search bar and middle of vw #}
<div class="col"></div>
<div class="col-8 nopadding border">
<form class="form-inline justify-content-center" id="formq" action="{% url 'query' %}" method="GET">
<div class="input-group stylish-input-group">
<input class="form-control text-center" id="search" type="search" size="128"
placeholder="{{ algo_name }}" value="{{ algo_name }}" aria-label="Search" name="q">
<span class="input-group-addon">
<button type="submit" style="outline: none;">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
</div>
<div class="col-0.5 border">
<button onclick="document.getElementById('search').value=''" class="btn btn-default btn-md">
<i class="fa fa-remove" style="color:#A4A2A2;"></i>
</button>
</div>
{# align search bar and middle of vw #}
<div class="col float-right"></div>
</div>
<br>
{% block body %} {% endblock %}

<div class="container">
<br>
<div class="row">
<div class="col-4">
<a class="navbar-brand" href="/">cosmos-search</a>
</div>
<div class="col-8">
<a class="btn float-right" href="https://github.com/OpenGenus/cosmos-search">GitHub</a>
<a class="btn float-right" href="https://github.com/OpenGenus/cosmos">cosmos</a>
<a class="btn float-right" href="/calculator/">calculator</a>
</div>
</div></br>
<div class="row">
{# align search bar and middle of vw #}
<div class="col"></div>
<div class="col-8 nopadding border">
<form class="form-inline justify-content-center" id="formq" action="/query/" method="GET">
<div class="input-group stylish-input-group">
<input class="form-control text-center" id="search" type="search" size="128" placeholder="{{ algo_name }}" value="{{ algo_name }}" aria-label="Search" name="q">
<span class="input-group-addon">
<button type="submit" style="outline: none;">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
</div>
<div class="col-0.5 border">
<button onclick="document.getElementById('search').value=''" class="btn btn-default btn-md">
<i class="fa fa-remove" style="color:#A4A2A2;"></i>
</button>
</div>
{# align search bar and middle of vw #}
<div class="col float-right"></div>
</div><br>
{% block body %} {% endblock %}
</div>
<footer class="footer">
<div class="text-muted" style="text-align: center">
Expand Down Expand Up @@ -162,5 +257,5 @@


</body>

</html>
3 changes: 3 additions & 0 deletions search/templates/cosmos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ <h4>a library of every algorithm and data structure code that you will ever enco
To search for an algorithm, just enter your search keywords in the box above.<br><br>
&mdash; <a href="http://opengenus.org">OpenGenus, The Open Group to help the needy</a>
<p>
{% for fetch in data %}
<h1>{{ Votes.project_name }}</h1>
{% endfor %}
</article>

{% endblock %}
Loading