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
23 changes: 16 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
## Contributing

### Contributing
Contribution are welcome as always. Checkout the existing issues or create issues if you encounter any problem with the project.

Contribution are welcome as always. Checkout the existing issues or create issues.
### Steps for contributing

Steps for contributing:
#### 1. Making Changes

- Fork and clone the repository
- Fork and clone the repository.

- If resolving an issue then create a branch with name like `bugfix-#<issue_number>` or `enhancement-#<issue_number>`
- Always branch from updated `development` branch locally.

- After commiting, push the branch to your upstream fork.
- If resolving an issue then create a branch with name like `bugfix-#<issue_number>` or `enhancement-#<issue_number>`.

- Create a Pull request to this repository
- Write a commit messages describing the changes you made

#### 2. Submitting Pull request

- Rebase your commits with latest changes from `development`.

- Push your changes to your upstream fork.

- Create a pull request to the `development` branch of the repository.
71 changes: 53 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,68 @@ A django application for sharing code snippets.


### Contributing
Please Checkout [CONTRIBUTING.md
](https://github.com/sourabhtk37/CodeShare/blob/master/CONTRIBUTING.md)


Contribution are welcome as always. Checkout the existing issues or create issues.

Steps for contributing:

- Fork and clone the repository
# CodeShare API

- If resolving an issue then create a branch with name like `bugfix-#<issue_number>` or `enhancement-#<issue_number>`
## GET

- After commiting, push the branch to your upstream fork.
api.domain/*hashid*.json

- Create a Pull request to this repository
### Data Format
```javascript
id : 5
hash_value : "81b9uc7llmjm"
code : "print ('hello world')"
file_name "mypythoncode"
language : "python"

```

# CodeShare API
##GET
###By id
domain/api/*id*.json
###by filename
domain/api/*filename*.json


##POST
see json format at [CodeShare](http://domain/api.com)
###new code file
domain/api
###update existing file
domain/api/*filename or id*
## POST

api.domain/

### Data Format
```javascript

code : "print ('hello world')"
file_name "mypythoncode"
language : "python"

```

## PUT
api.domain/*hashid*/


### Data Format
```javascript

code : "print ('hello world')"
file_name "mypythoncode"
language : "python"

```

####Every Post request will give the new object made or updated ,in response

#### Bug Fix

> The django-subdomains contains a small bug and here is the fix

In your site-pakages/subdomains/middleware.py make a slightly change in you SubdomainMiddleware class

```python

from django.utils.deprecation import MiddlewareMixin

class SubdomainMiddleware(MiddlewareMixin):

```
7 changes: 0 additions & 7 deletions code_share/api_app/apps.py

This file was deleted.

9 changes: 0 additions & 9 deletions code_share/api_app/serializers.py

This file was deleted.

12 changes: 0 additions & 12 deletions code_share/api_app/urls.py

This file was deleted.

74 changes: 0 additions & 74 deletions code_share/api_app/views.py

This file was deleted.

6 changes: 5 additions & 1 deletion code_share/app_code_share/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from django.contrib import admin
from .models import CodeShare

admin.site.register(CodeShare)

@admin.register(CodeShare)
class CodeShareAdmin(admin.ModelAdmin):
exclude = ('id',)
list_display = ('hash_value', 'language','file_name')
7 changes: 7 additions & 0 deletions code_share/app_code_share/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from django.db import models



class CodeShare(models.Model):
"""
Databse schema for handline the code snippet data
Expand All @@ -10,6 +11,7 @@ class CodeShare(models.Model):
:field code: text field for code content
:field hash_value: unique hash ID for distinguishing code snipeets
:field file_name: character field for file name
:field language: type of programming language


"""
Expand All @@ -28,6 +30,11 @@ class CodeShare(models.Model):
null=True,
blank=True)

language = models.CharField(max_length=20,
null=True,
blank=True,
default=None)

def __unicode__(self):
return str(self.hash_value)

Expand Down
15 changes: 15 additions & 0 deletions code_share/app_code_share/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from rest_framework import serializers
from app_code_share.models import CodeShare

class Codeserializer(serializers.ModelSerializer):
"""
Used to convert and map model Codeshare with API
format(json)

"""
hash_value=serializers.CharField(read_only=True)

class Meta:
model = CodeShare
fields ="__all__"

9 changes: 8 additions & 1 deletion code_share/app_code_share/templates/app_code_share/base.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load staticfiles %}
{% include "fork_github.html" %}
{% load staticfiles %}

<!DOCTYPE html>

Expand All @@ -11,6 +11,13 @@
<title>Shitty Code Share</title>
<link rel="stylesheet" href="{% static 'css/normalize.css' %}">
<link rel="stylesheet" href="{% static 'css/milligram.css' %}">
<link rel="stylesheet" href="{% static 'css/codemirror.css' %}"/>
<link rel="stylesheet" href="{% static 'css/neo.css' %}" />

<script type="text/javascript" src="{% static 'js/codemirror.js' %}"></script>
<script type="text/javascript" src="{% static 'js/highlight.js' %}"></script>
<script type="text/javascript" src="{% static 'js/loadmode.js' %}"></script>


{% block css %}

Expand Down
54 changes: 22 additions & 32 deletions code_share/app_code_share/templates/app_code_share/code_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,46 +9,36 @@

{% block body %}

<div class="container">
<div class="container">

{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

<button id="copy_button">Copy</button>
<input type="url" id="link_box" style="float: right;">

<form action="." enctype="multipart/form-data" method="POST">
{% csrf_token %}

{% if code_share.file_name %}
<h4>File Name: {{code_share.file_name}}</h4>

{%endif%}

<textarea id="code_snippet" name="code_snippet">{{code_share.code}}</textarea><br>
<input id="submit_edit" type="submit" value="edit">
<br>
<a href="{% url 'code_share:app_home'%}" >
<div id="create">create new</div>
</a><br>

</form>
<button id="copy_button">Copy</button>
<input type="url" id="link_box" style="float: right;">

<form action="." enctype="multipart/form-data" method="POST">
{% csrf_token %}

{% if code_share.file_name %}
<h4>File Name: {{code_share.file_name}}</h4>
{%endif%}

<textarea id="code_snippet" name="code_snippet">{{code_share.code}}</textarea><br>
<input id="language" name="language" value="{{code_share.language}}" hidden>
<input id="submit_edit" type="submit" value="edit"><br>
<a href="{% url 'code_share:app_home'%}" >
<div id="create">create new</div>
</a><br>

</form>

<blockquote>
<p><em>Share your shitty code here. nothing is necessary. Put code and submit.BAM.</em></p>
</blockquote>

</div>

</div>

{% endblock %}


{% block scripts%}
<script type="text/javascript" crossorigin="anonymous" src="{% static 'js/codeshare.js' %}"></script>
{% endblock %}
<script type="text/javascript" crossorigin="anonymous" src="{% static 'js/codeshare.js' %}"></script>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@

<div class="container">

{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}

<form action="." enctype="multipart/form-data" method="POST">
{% csrf_token %}

<input type="text" id="file_field" name="file_name" placeholder="File Name" value="{{code_share.file_name}}">
<textarea id="code_snippet" name="code_snippet" placeholder="Code Snippet">{{code_share.code}}</textarea><br>
<input id="language" name="language" value="None" hidden>
<input id="submit_new" type="submit" value="submit" ><br>

</form>
Expand Down
Loading