From 18c8fa7b0cffbf353c8854e6cab5daf9c90a36ea Mon Sep 17 00:00:00 2001 From: ayushnagar123 Date: Mon, 2 Dec 2019 04:01:14 +0530 Subject: [PATCH 1/2] Flask api for image to template conversion added. Readme Updated. --- README.md | 20 ++++++++++++- backend/requirements.txt | 6 ++++ backend/run.py | 56 ++++++++++++++++++++++++++++++++++++ backend/run.pyc | Bin 0 -> 2525 bytes src/App.vue | 4 +++ src/router.js | 42 ++++++++++++++++++--------- src/views/CreateBadge.vue | 26 +++++++++++++++++ src/views/Upload/Upload.vue | 9 ++++++ 8 files changed, 148 insertions(+), 15 deletions(-) create mode 100644 backend/requirements.txt create mode 100644 backend/run.py create mode 100644 backend/run.pyc create mode 100644 src/views/CreateBadge.vue create mode 100644 src/views/Upload/Upload.vue diff --git a/README.md b/README.md index ead071e..dfb3f52 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,8 @@ Well we all have been working in Open Source and committing various Pull request - Real time tracking of commits, PR's and other contributions. - Contributors list based on number of PR's, merged pulls and other activities. - Contribution history of each contributor. +can create a badge for your organization.] +- upload and use the templates The other part of this project includes the “notifying moderator” since we see sometimes that there are many PRs being sent, or issues being opened by various people across the globe but there are limited numbers of maintainers merging the PRs. This way organisations usually lose their potential contributors due to following things: @@ -26,9 +28,25 @@ The other part of this project includes the “notifying moderator” since we s For instance, suppose a contributor “X” has been quite active within the community by working on various PRs, opening and resolving various issues, active on chat channels but after a month “X” gets disappeared. So by using this dashboard they will have a badge interface. There will be a badge attached in front of the name of the contributor. Let the name of the badge be “Y” so this badge will have a unique color. So as the time passes like “ a day went, 1 week went, 2 weeks went, a month, etc) this badges will get keep on fading. And Every fade color will have a unique reason. For example, when a contributor made a PR, the badge appeared “Red” in color. This badge will remain in the same color as long as he/she is contributing. Assume that contributor stops contributing and has not contributed for a week so his badge will become green in color. And this will keep on notifying mainaters, Admins about their disappearing. This way the organisations will have greater eye on the contributors and can help them sustain with the community. +## Install and Run + +**Step 1:-** clone the repository + +``` git clone https://github.com/username/Codebadge.git ``` +**Step 2:-** install frontend dependencies and run frontend server +``` npm install && npm run serve``` +**Step 3:-** install flask api dependencies and run api +``` +cd backend +virtualenv -p python3 venv +source venv/bin/activate +pip install -r requirements.txt +FLASK_APP=run.py flask run +``` + ## Stack used -This will have a dashboard, where these things can be placed. The stack used can be any but since the organisation have fixed stack so its better to stick to Nodejs, Vue, React. +This will have a dashboard, where these things can be placed. The stack used can be any but since the organisation have fixed stack so its better to stick to Nodejs, Vue, React. Flask is used as an machine learning api. ## Benefits to the community diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..a9dfc70 --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,6 @@ +Flask==1.1.1 +Flask-Cors==3.0.8 +numpy==1.16.5 +opencv-python==4.1.1.26 +requests==2.22.0 +Werkzeug==0.16.0 \ No newline at end of file diff --git a/backend/run.py b/backend/run.py new file mode 100644 index 0000000..584680f --- /dev/null +++ b/backend/run.py @@ -0,0 +1,56 @@ +from flask import Flask, render_template, jsonify,send_file,request +from random import * +from flask_cors import CORS +import requests +import numpy as np +from cv2 import cv2 +from werkzeug.utils import secure_filename +import os +app = Flask(__name__, + static_folder = "./dist/static", + template_folder = "./dist") +cors = CORS(app, resources={r"/api/*": {"origins": "*"}}) + +@app.route('/api/random') +def random_number(): + response = { + 'randomNumber': randint(1, 100) + } + return jsonify(response) + +@app.route('/api/upload',methods=["POST"]) +def upload(): + # file=request.files['temp'] + f=request.files['temp'] + tempname=request.form['tempname'] + temp_path='../templates/' + name = f.filename.replace(' ','_') + print(tempname) + f.save(secure_filename(f.filename)) + + inputImage = cv2.imread(name) + inputImageGray = cv2.cvtColor(inputImage, cv2.COLOR_BGR2GRAY) + + edges = cv2.Canny(inputImageGray,150,200,apertureSize = 3) + + print(edges) + edges = abs(cv2.subtract(255,edges)) + + minLineLength = 30 + maxLineGap = 5 + lines = cv2.HoughLinesP(edges,cv2.HOUGH_PROBABILISTIC, np.pi/180, 30, minLineLength,maxLineGap) + for x in range(0, len(lines)): + for x1,y1,x2,y2 in lines[x]: + pts = np.array([[x1, y1 ], [x2 , y2]], np.int32) + cv2.polylines(inputImage, [pts], True, (0,255,0)) + + font = cv2.FONT_HERSHEY_SIMPLEX + cv2.putText(inputImage,"Tracks Detected", (500, 250), font, 0.5, 255) + + cv2.imwrite(temp_path+tempname+'.jpeg',edges) + cv2.waitKey(0) + + os.remove(name) + + filename=tempname+'.jpeg' + return send_file(temp_path+filename,mimetype='image/jpeg') \ No newline at end of file diff --git a/backend/run.pyc b/backend/run.pyc new file mode 100644 index 0000000000000000000000000000000000000000..265a349ed721c33791e78232765ee81d789c3061 GIT binary patch literal 2525 zcmb_d+j1L45barAEXle#zUGQ~0aYHXic*yqC?Js&+l8@RD^VdT!q!?lmPgrJc4iYP zB~etFZ{SOKFMj4?%v!VwaO3nFE591`L~4cFYu@T z!NtQzfDaG|7zhX~7+4VGV330#4}&}e1sD`Skemg65&A^sz+Zx(1cOp`k_W#GgECt~ zx&nh`rVHR#A*jNjn#mQxuR&0ULH$av0fPoe0kR3+5_l!>&`bp`gf&h+29LZtJh~8KaDxuVtKcvU_azjnjT$;+>qzOR=TWa5Ti6mWr1>>M<{^)@aDyWtwa z>%Xw*>L1NH#~Fj&YmxL3N};HSi>cz089YjZQ<=0Z;!+62RiUwokwH)*uGDc9YS}^> zc+sCA)jp2`*>^?|Z0}0EoG5OOlsQjN+ug{Mr>-}W?NfL73h$$xq~T6H zWfZdzoRDLvqe0FbtejZ2t}{<#KXN^e4$(i4JZ&hSljB~W;kbbty6r9*_zjapEXG)C z0&WrtxIsuP+#oLpa|;laaSq0LsxYrWh|O~_6R@{WCj~IYOA#zod<424mtdBo%{)&y zjmt302M;&A?!>j;a@w!JYa$=6Qif9=jCy^TU4Kh%PjG^o@%(11aFfXw{olZ%z z0j3FK?2a0&qtI*#W+k{N!n_QV@4;Zt)WNL6tW1W`-0sT}%quYYj##q_+}wR>!?$^u zqXV>FgE`8h#Wk3rwJMAdhZ@Z4MBqb5>zoTZM)w<(;H*JyX*R*zfQvkc*GuC0>%ZVR z32ec<$&xoo65HF`gc;5U3=A0D zJG!UdNk!eR-qUiA7HUQHGcEW7P3_-LuyFPEt~7FJq^JJG3R8dM!H7fve*avP*3LMV zBMvH1SfI$+|;9~95S&LnfM&^$w?z?M?tq+iAQ*ra4qsf)k`dO3&Y@1j-gt%8F zj=iB|NVNM#+60MBCs@JcI+55n#2mgc-N=s;LrvB_K0LOaCwq2h&wl)ZJ$2nMoEi$y zJ=LtC(^G?q8$$zVKT1dEhbol%1WOM0$6xR5J16$>lgCdE4i9?$gRY^05yt$A6&uCw z9!WNeF*C_4@8`%hmuy@Rh#4xfI5 zWd{(arY|RkX%)Op)aBfN>nii5oN@q>W&jcyM2HHd)uJK6)o^B$d3H_J;>4~wXV(lX zUs;Gg4(Q$(E_JotTSPB$o@t(7feHziLm7_H3~2}MggAR{%!y{H(d3q^mi`6KYY?XZ literal 0 HcmV?d00001 diff --git a/src/App.vue b/src/App.vue index a3c22fb..666c32a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,6 +2,7 @@ + upload file Codebadge  (Production Stage) @@ -29,4 +30,7 @@ export default { .content { background-color: white; } +a{ + float:right; +} \ No newline at end of file diff --git a/src/router.js b/src/router.js index c401a77..ac23201 100644 --- a/src/router.js +++ b/src/router.js @@ -1,36 +1,50 @@ -import Vue from 'vue'; -import Router from 'vue-router'; -import AuthView from './views/AuthView'; -import HomeView from './views/HomeView'; -import OrgView from './views/OrgView'; -import AuthService from './services/authService'; +import Vue from "vue"; +import Router from "vue-router"; +import AuthView from "./views/AuthView"; +import HomeView from "./views/HomeView.vue"; +import OrgView from "./views/OrgView"; +import AuthService from "./services/authService"; +import CreateBadge from "./views/CreateBadge"; +import Upload from "./views/Upload/Upload.vue"; Vue.use(Router); const authService = new AuthService(); export default new Router({ + mode: "history", + base: process.env.BASE_URL, routes: [ { - path: '', - redirect: 'auth' + path: "", + redirect: "auth" }, { - path: '/auth', - name: 'authView', + path: "/upload", + name: "Upload", + component: Upload + }, + { + path: "/auth", + name: "authView", component: AuthView }, { - path: '/home', - name: 'homeView', + path: "/create", + name: "CreateBadge", + component: CreateBadge + }, + { + path: "/home", + name: "homeView", component: HomeView, beforeEnter: (to, from, next) => { next(authService.isLoggedIn()); } }, { - path: '/org/:name', - name: 'orgView', + path: "/org/:name", + name: "orgView", component: OrgView, beforeEnter: (to, from, next) => { next(authService.isLoggedIn()); diff --git a/src/views/CreateBadge.vue b/src/views/CreateBadge.vue new file mode 100644 index 0000000..8feca46 --- /dev/null +++ b/src/views/CreateBadge.vue @@ -0,0 +1,26 @@ + + diff --git a/src/views/Upload/Upload.vue b/src/views/Upload/Upload.vue new file mode 100644 index 0000000..38ad74a --- /dev/null +++ b/src/views/Upload/Upload.vue @@ -0,0 +1,9 @@ + From ba6d67010a551e7379dced50e89bc1ba8399208e Mon Sep 17 00:00:00 2001 From: Ayush Nagar <32647423+ayushnagar123@users.noreply.github.com> Date: Mon, 2 Dec 2019 09:17:00 +0530 Subject: [PATCH 2/2] Removed Readme typos --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dfb3f52..488b870 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Well we all have been working in Open Source and committing various Pull request - Real time tracking of commits, PR's and other contributions. - Contributors list based on number of PR's, merged pulls and other activities. - Contribution history of each contributor. -can create a badge for your organization.] +- Can create a badge for your organization. - upload and use the templates The other part of this project includes the “notifying moderator” since we see sometimes that there are many PRs being sent, or issues being opened by various people across the globe but there are limited numbers of maintainers merging the PRs. This way organisations usually lose their potential contributors due to following things: @@ -33,9 +33,14 @@ For instance, suppose a contributor “X” has been quite active within the com **Step 1:-** clone the repository ``` git clone https://github.com/username/Codebadge.git ``` + **Step 2:-** install frontend dependencies and run frontend server + ``` npm install && npm run serve``` + + **Step 3:-** install flask api dependencies and run api + ``` cd backend virtualenv -p python3 venv