diff --git a/doccano/app/app/__init__.py b/doccano/app/app/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/doccano/app/app/settings.py b/doccano/app/app/settings.py new file mode 100644 index 00000000..f2171734 --- /dev/null +++ b/doccano/app/app/settings.py @@ -0,0 +1,124 @@ +""" +Django settings for app project. + +Generated by 'django-admin startproject' using Django 2.0.5. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/2.0/ref/settings/ +""" + +import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) +BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'v8sk33sy82!uw3ty=!jjv5vp7=s2phrzw(m(hrn^f7e_#1h2al' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'app.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [os.path.join(BASE_DIR, 'server/templates')], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +STATICFILES_DIRS = [ + os.path.join(BASE_DIR, 'server/static'), +] + +WSGI_APPLICATION = 'app.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/2.0/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), + } +} + + +# Password validation +# https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/2.0/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_L10N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/2.0/howto/static-files/ + +STATIC_URL = '/static/' diff --git a/doccano/app/app/urls.py b/doccano/app/app/urls.py new file mode 100644 index 00000000..2705cfc8 --- /dev/null +++ b/doccano/app/app/urls.py @@ -0,0 +1,24 @@ +"""app URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/2.0/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: path('', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.urls import include, path + 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) +""" +from django.contrib import admin +from django.urls import path + +from doccano.app.server.views import AnnotationView + +urlpatterns = [ + path('annotation/', AnnotationView.as_view()), + path('admin/', admin.site.urls), +] diff --git a/doccano/app/app/wsgi.py b/doccano/app/app/wsgi.py new file mode 100644 index 00000000..21ff6e61 --- /dev/null +++ b/doccano/app/app/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for app project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/2.0/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") + +application = get_wsgi_application() diff --git a/doccano/app/manage.py b/doccano/app/manage.py new file mode 100755 index 00000000..e031798a --- /dev/null +++ b/doccano/app/manage.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) diff --git a/doccano/app/server/__init__.py b/doccano/app/server/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/doccano/app/server/admin.py b/doccano/app/server/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/doccano/app/server/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/doccano/app/server/apps.py b/doccano/app/server/apps.py new file mode 100644 index 00000000..f6bd99a1 --- /dev/null +++ b/doccano/app/server/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ServerConfig(AppConfig): + name = 'server' diff --git a/doccano/app/server/migrations/__init__.py b/doccano/app/server/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/doccano/app/server/models.py b/doccano/app/server/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/doccano/app/server/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/doccano/app/server/static/bulma.js b/doccano/app/server/static/bulma.js new file mode 100644 index 00000000..23ffa0a4 --- /dev/null +++ b/doccano/app/server/static/bulma.js @@ -0,0 +1,10 @@ +// The following code is based off a toggle menu by @Bradcomp +// source: https://gist.github.com/Bradcomp/a9ef2ef322a8e8017443b626208999c1 +(function() { + var burger = document.querySelector('.burger'); + var menu = document.querySelector('#'+burger.dataset.target); + burger.addEventListener('click', function() { + burger.classList.toggle('is-active'); + menu.classList.toggle('is-active'); + }); +})(); \ No newline at end of file diff --git a/doccano/app/server/static/forum.css b/doccano/app/server/static/forum.css new file mode 100644 index 00000000..1f54737b --- /dev/null +++ b/doccano/app/server/static/forum.css @@ -0,0 +1,68 @@ +html,body { + font-family: 'Open Sans', serif; + background: #F9F9F9; +} +footer { + background-color: #F2F6FA !important; +} +.topNav { + border-top: 5px solid #3498DB; +} +.topNav .container { + border-bottom: 1px solid #E6EAEE; +} +.container .columns { + margin: 2rem 0; +} +.navbar-menu .navbar-item { + padding: 0 2rem; +} +aside.menu { + padding-top: 3rem; +} +aside.menu .menu-list { + line-height: 1.5; +} +aside.menu .menu-label { + padding-left: 10px; + font-weight: 700; +} +.button.is-primary.is-alt { + background: #00c6ff; + background: -webkit-linear-gradient(to bottom, #0072ff, #00c6ff); + background: linear-gradient(to bottom, #0072ff, #00c6ff); + font-weight: 700; + font-size: 14px; + height: 3rem; + line-height: 2.8; +} +.media-left img { + border-radius: 50%; +} +.media-content p { + font-size: 14px; + line-height: 2.3; + font-weight: 700; + color: #8F99A3; +} +article.post { + margin: 1rem; + padding-bottom: 1rem; + border-bottom: 1px solid #E6EAEE; +} +article.post:last-child { + padding-bottom: 0; + border-bottom: none; +} +.menu-list li{ + padding: 5px; +} + +.tag:not(body).is-grey { + background-color: #eee; + color: #666; +} + +p { + font-family: "游ゴシック体", YuGothic, "YuGothic M", sans-serif; +} \ No newline at end of file diff --git a/doccano/app/server/static/images/logo.png b/doccano/app/server/static/images/logo.png new file mode 100644 index 00000000..31a1a328 Binary files /dev/null and b/doccano/app/server/static/images/logo.png differ diff --git a/doccano/app/server/static/main.js b/doccano/app/server/static/main.js new file mode 100644 index 00000000..98d3a2bc --- /dev/null +++ b/doccano/app/server/static/main.js @@ -0,0 +1,32 @@ +Vue.config.debug = true; + +var app4 = new Vue({ + el: '#app', + delimiters: ['[[', ']]'], + data: { + cur: 2, + items: [ + {"id": 10, "labels": [{"text": "Prefecture", "prob": 0.98}, {"text": "Domestic Region", "prob": 0.58}], "text": "北海道(ほっかいどう)は、日本の北部に位置する島[※ 1][※ 2]。また、同島および付随する島を管轄する地方公共団体(道)である。島としての北海道は日本列島を構成する主要4島の一つである。地方公共団体としての北海道は47都道府県中唯一の「道」で、道庁所在地は札幌市。"}, + {"id": 11, "labels": [{"text": "Person", "prob": 0.98}], "text": "安倍 晋三(あべ しんぞう、1954年(昭和29年)9月21日 - )は、日本の政治家。自由民主党所属の衆議院議員(9期)、第90代・第96代・第97代・第98代内閣総理大臣、第21代・第25代自由民主党総裁。"}, + {"id": 12, "labels": [{"text": "Country", "prob": 0.98}, {"text": "Continental Region", "prob": 0.58}], "text": "アメリカ合衆国(アメリカがっしゅうこく、英語: United States of America)、通称アメリカ、米国(べいこく)は、50の州および連邦区から成る連邦共和国である[6][7]。アメリカ本土の48州およびワシントンD.C.は、カナダとメキシコの間の北アメリカ中央に位置する。アラスカ州は北アメリカ北西部の角に位置し、東ではカナダと、西ではベーリング海峡をはさんでロシアと国境を接している。ハワイ州は中部太平洋における島嶼群である。同国は、太平洋およびカリブに5つの有人の海外領土および9つの無人の海外領土を有する。985万平方キロメートル (km2) の総面積は世界第3位または第4位、3億1千7百万人の人口は世界第3位である。同国は世界で最も民族的に多様かつ多文化な国の1つであり、これは多くの国からの大規模な移住の産物とされている[8]。また同国の広大な国土における地理および気候も極めて多様であり、多種多様な野生生物が存在する。"}, + ], + labels: [ + 'Location', 'Organization', 'Person' + ], + guideline: 'annotation text' + }, + methods: { + addLabel: function (label) { + this.items[this.cur]['labels'].push({"text": label, "prob":null}) + }, + deleteLabel: function (index) { + this.items[this.cur]['labels'].splice(index, 1) + }, + nextPage: function () { + this.cur += 1 + }, + prevPage: function () { + this.cur -= 1 + } + } +}) \ No newline at end of file diff --git a/doccano/app/server/templates/annotation.html b/doccano/app/server/templates/annotation.html new file mode 100644 index 00000000..842831fb --- /dev/null +++ b/doccano/app/server/templates/annotation.html @@ -0,0 +1,129 @@ +{% load static %} + + + + + + + Forum - Free Bulma template + + + + + + + + + + + +
+
+ +
+
+
+ +
+
+

+
+ +
+
+ + + + [[label.text]] + + [[label.prob]] +
+
+
+

+
+
+
+

+ [[items[cur].text]] +

+
+
+
+
+
+
+ +
+ +
+ +
+ +
+ +
+ + +
+ + Learn & Classify + + +
+
+ +
+
+ + + + \ No newline at end of file diff --git a/doccano/app/server/tests.py b/doccano/app/server/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/doccano/app/server/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/doccano/app/server/views.py b/doccano/app/server/views.py new file mode 100644 index 00000000..2c128167 --- /dev/null +++ b/doccano/app/server/views.py @@ -0,0 +1,10 @@ +from django.shortcuts import render +from django.views import View + + +class AnnotationView(View): + template_name = 'annotation.html' + + def get(self, request, *args, **kwargs): + # form = self.form_class(initial=self.initial) + return render(request, self.template_name) diff --git a/doccano/server/run_server.py b/doccano/server/run_server.py index d30c9cea..dbe76c9f 100644 --- a/doccano/server/run_server.py +++ b/doccano/server/run_server.py @@ -8,7 +8,7 @@ from tornado.web import url class IndexHandler(tornado.web.RequestHandler): def get(self): - self.render('index2.html') + self.render('annotation.html') def post(self): pass