Skip to content

Commit 3f2c019

Browse files
Hail reactjs
1 parent e705836 commit 3f2c019

File tree

11 files changed

+159
-24
lines changed

11 files changed

+159
-24
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
npm-debug.log
33
node_modules
44
todo.txt
5+
main.py
6+
rough.js
7+
rough2.js

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default {
55
title: 'Codeforces Handle',
66
order: 1,
77
type: 'string',
8-
default: 'blueedgetechno'
8+
default: 'blue_edge'
99
},
1010

1111
programmingLanguage: {

lib/view/actions.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ const Actions = ({prob})=>{
2626
<button className="actionbutton">Run all</button>
2727
</div>
2828
<div className="down">
29-
<div className="verdict"> <span>example 1</span> <i className="icon icon-check"></i> </div>
30-
<div className="verdict"> <span>example 2</span> <i className="icon icon-x"></i> </div>
31-
<div className="verdict"> <span>example 3</span> <i className="icon icon-clock"></i> </div>
32-
<div className="verdict"> <span>example 3</span> <i className="icon icon-alert"></i> </div>
29+
{prob.tests && prob.tests.map(test=>{
30+
return <div className="verdict"> <span>example {test.i}</span> <i className="icon-check"></i> </div>
31+
})}
3332
</div>
3433
</div>
3534
<div className="task">
@@ -50,3 +49,8 @@ const Actions = ({prob})=>{
5049
}
5150

5251
export default Actions;
52+
53+
// check
54+
// x
55+
// clock
56+
// alert

lib/view/index.js

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ function couple(x) {
2626
export default class Root extends React.PureComponent {
2727
constructor(props){
2828
super(props);
29-
// this.state = { desc: "", id: "", changed: 0, timeremaining: 0};
30-
this.state = { desc: "Codeforces Round #663 (Div. 2)", id: 1176, changed: 2, timeremaining: 0}
29+
// this.state = { desc: "", id: "", changed: 0, timeremaining: 0"};
30+
this.state = {
31+
desc: "Codeforces Round #663 (Div. 2)",
32+
id: 1391,
33+
changed: 2,
34+
timeremaining: 0,
35+
profimg: "//templates.joomla-monster.com/joomla30/jm-news-portal/components/com_djclassifieds/assets/images/default_profile.png"
36+
}
3137
}
3238

3339
fetch(url){
@@ -118,12 +124,33 @@ export default class Root extends React.PureComponent {
118124
if(event.target){
119125
this.setState({id: event.target.value});
120126
}
121-
// console.log(this.state);
127+
}
128+
129+
fetchprofileimage(){
130+
var url = "https://codeforces.com/api/user.info?handles="+atom.config.get("codeblue.codeforcesHandle")
131+
fetch(url)
132+
.then(res=> res.json())
133+
.then(res=> this.setState({profimg: res.result[0].titlePhoto}))
134+
.catch(err => console.log("Error");)
135+
}
136+
137+
Loadprofile({profimg}){
138+
var handle = atom.config.get("codeblue.codeforcesHandle")
139+
return (
140+
<div className="profile">
141+
<div className="profile-image">
142+
<img src={"https:"+profimg}/>
143+
</div>
144+
<span>{handle}</span>
145+
</div>
146+
)
122147
}
123148

124149
render() {
150+
this.fetchprofileimage()
125151
return (
126152
<div>
153+
<this.Loadprofile profimg={this.state.profimg}/>
127154
{this.state.changed ? <h2>{this.state.desc}</h2> : null}
128155

129156
{this.state.changed==0 ? (

lib/view/problem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const Problem = ({prob,changer})=>{
1919
return (
2020
<div onClick={changer} className="prob">
2121
<span>{prob.alpha} - {prob.name}</span>
22-
<span className="totsub"> <i className="icon icon-person"></i> {prob.sub}</span>
22+
<span className="totsub"><i className="icon-person"></i>{prob.sub}</span>
2323
{currentstate}
2424
</div>
2525
)

lib/view/problems.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,24 @@ export default class Problems extends React.PureComponent {
4444
})
4545
}
4646

47+
createnv(){
48+
const setup = require('./setup');
49+
var wd = atom.config.get("codeblue.workingDirectory")
50+
wd = wd.split("\\")
51+
wd = wd.join("/")
52+
if(wd.substring(-1)!="/"){
53+
wd+="/"
54+
}
55+
56+
for (var prob of this.state.probs) {
57+
setup(wd, { alpha: prob.alpha, tot: 2} , ".py")
58+
}
59+
}
60+
61+
loadsamplecases(){
62+
// console.log("Heelo");
63+
}
64+
4765
scrape(html){
4866
$ = cheerio.load(html)
4967
var i = 2
@@ -55,11 +73,12 @@ export default class Problems extends React.PureComponent {
5573
}else{
5674
var nm = $(`#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child(${i}) > td:nth-child(2) > div > div:nth-child(1) > a`).text().trim()
5775
var sub = $(`#pageContent > div.datatable > div:nth-child(6) > table > tbody > tr:nth-child(${i}) > td > a`).text().trim().substring(2)
58-
probs.push({alpha: al, name: nm, con: i%6-1, test: 1, sub: sub});
76+
probs.push({alpha: al, name: nm, con: -1, test: 1, sub: sub, notc: 0, tests: [] });
5977
}
6078
i++;
6179
}
6280
this.setState({probs: probs})
81+
this.loadsamplecases()
6382
}
6483

6584
componentWillMount(){

lib/view/rough.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const setup = require('./setup');
22

3-
setup("C:/Users/Rohan/OneDrive/Atom/codeforces",[{alpha: "A"}])
3+
setup("C:/Users/Rohan/OneDrive/Atom/codeforces/", { alpha: "B", tot: 2} , ".py")

lib/view/setup.js

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
1-
const {Node} = require("graph-fs");
1+
const fs = require('fs');
22

3-
const emptyit = (path) => {
4-
const directory = new Node(path);
5-
directory.clear();
6-
}
3+
const setup = (path, prob, ext) => {
4+
5+
var dir = path + prob.alpha
6+
var fl = dir + "/" + prob.alpha + ext
7+
var exp = dir + "/examples/"
8+
var tests = []
9+
for (var i = 1; i <= prob.tot; i++) {
10+
tests.push(exp + "input" + i + ".in")
11+
tests.push(exp + "output" + i + ".out")
12+
}
13+
14+
fs.mkdir(dir, (err) => {
15+
if (err && err.code!='EEXIST') console.log("Error while creating problem folder",err.code);
16+
else {
17+
fs.writeFile(fl, "", (err) => {
18+
if (err && err.code!='EEXIST') console.log("Error while creating source file", err);
19+
})
720

8-
const setup = (path, probs) => {
9-
emptyit(path)
10-
console.log(path);
21+
fs.mkdir(exp, (err) => {
22+
if (err && err.code!='EEXIST') console.log("Error while creating example folder", err);
23+
else {
24+
for (var test of tests) {
25+
fs.writeFile(test, "", (err) => {
26+
if (err && err.code!='EEXIST') console.log("Error while creating input/output file");
27+
})
28+
}
29+
}
30+
})
31+
}
32+
})
1133
}
1234

1335
module.exports = setup

package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"dependencies": {
1616
"cheerio": "^1.0.0-rc.3",
1717
"child_process": "^1.0.2",
18+
"fs": "0.0.1-security",
19+
"path": "^0.12.7",
1820
"react": "^16.13.1",
1921
"react-dom": "^16.13.1",
2022
"request": "^2.88.2"

0 commit comments

Comments
 (0)