Skip to content

Commit 74ec1e4

Browse files
Now you also test and run c and c++ files
1 parent 6930d37 commit 74ec1e4

File tree

9 files changed

+246
-63
lines changed

9 files changed

+246
-63
lines changed

README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
## An Atom package for all your competitive coding needs
1212
<br>
1313

14+
![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/face.png)
1415

1516
### Installation
1617
Step 1.
@@ -32,25 +33,31 @@ oj l https://codeforces.com/
3233
- Automatically create an environment for contest including working files 💻
3334
- Run code with official sample cases of any particular problem 🔭
3435
- Compare your output with expected output in a elegant manner 📺
35-
- Get your code verdicts like OK ✅, Wrong answer ❌, TLE 🕒, MLE 🛢, Runtime error ⚠, Queue ⏳, Hacked ☠️
36+
- Get your code verdicts like OK ✅, Wrong answer ❌, TLE 🕒, MLE 🛢, Runtime error or Compilation error ⚠, Queue ⏳, Hacked ☠️
3637
- Submit 🏳‍🌈 your code from your favorite text editor
3738
- Get your official standing of the live contest 👥
3839
- Play minigames while you wait for the contest 🎮
3940

41+
## Updates
42+
- Now supports the feature to test and run C++(g++ compiler) and C (gcc compiler) language codes 🎉🎊
43+
- Option to run code for case independent problems 📡
44+
4045
## Guide
4146
- Set your preferences in settings of the package, in advance
47+
- Delete the folders and files of working directory before contest
4248
- Click on Refresh button to refresh the standing
4349
- Click on your standing to minimize problems view
4450
- Click on your profile picture to refresh problems
4551
- Click on an example number to copy its input data
4652

4753
## Limitations
48-
- Currently, test and run code option is only available for python users
4954
- I will try to remove the dependency of online-judge-tools for non-python users in future updates
5055

51-
<br>
56+
- While running C or C++ files, it sometimes run the previously compiled file and shows the same verdict. Incase of that delete the previously compiled file and run the code again
5257

53-
![overview](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/face.png)
58+
##### Any feedback will be highly appreciable
59+
60+
<br>
5461

5562
![work](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/work.png)
5663
<hr>
@@ -76,4 +83,3 @@ oj l https://codeforces.com/
7683

7784
# MLE - Its a thing too
7885
![TLE](https://raw.githubusercontent.com/blueedgetechno/codeblue/master/img/mle.png)
79-
<hr>

lib/view/actions.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ export default class Actions extends React.PureComponent {
1212
outputs: props.outputs,
1313
tests: props.tests,
1414
runexamples: props.runexamples,
15-
submitsolution: props.submitsolution
15+
submitsolution: props.submitsolution,
16+
changeignorevalue: props.changeignorevalue
1617
}
1718
}
1819

@@ -23,19 +24,20 @@ export default class Actions extends React.PureComponent {
2324
outputs: nextProps.outputs,
2425
tests: nextProps.tests,
2526
runexamples: nextProps.runexamples,
26-
submitsolution: nextProps.submitsolution
27+
submitsolution: nextProps.submitsolution,
28+
changeignorevalue: nextProps.changeignorevalue
2729
});
2830
}
2931

30-
change(ele){
31-
if(ele==null) return
32-
ele.target.classList.toggle("icon-chevron-right")
33-
ele.target.classList.toggle("icon-chevron-down")
34-
var val = ele.target.parentElement.nextElementSibling.style.display
32+
change(){
33+
var ele = this.refs.chevronbutton
34+
ele.classList.toggle("icon-chevron-right")
35+
ele.classList.toggle("icon-chevron-down")
36+
var val = this.refs.down.style.display
3537
if(val=="flex"){
36-
ele.target.parentElement.nextElementSibling.style.display = "none";
38+
this.refs.down.style.display = "none";
3739
}else{
38-
ele.target.parentElement.nextElementSibling.style.display = "flex";
40+
this.refs.down.style.display = "flex";
3941
}
4042
}
4143

@@ -88,13 +90,22 @@ export default class Actions extends React.PureComponent {
8890
return (
8991
<div className="actions">
9092
<h2 className="title titlename">{this.state.prob.index} - {this.state.prob.name}</h2>
93+
<div className="addoption">
94+
<div className="igcasediv">
95+
<input ref="igcase" type="checkbox" name="igcase" checked={this.state.prob.ignorecase} onChange={this.state.changeignorevalue}/>
96+
<span>Ignore case</span>
97+
</div>
98+
</div>
9199
<div className="tasks">
92100
<div className="task">
93101
<div className="up">
94-
<span onClick={this.change.bind(this)} className="icon icon-chevron-right">Examples</span>
95-
<button className="actionbutton" onClick={this.state.runexamples}>Run all</button>
102+
<span ref="chevronbutton" onClick={this.change.bind(this)} className="icon icon-chevron-right">Examples</span>
103+
<button className="actionbutton" onClick={()=>{
104+
this.state.runexamples()
105+
this.refs.down.style.display = "flex"
106+
}}>Run all</button>
96107
</div>
97-
<div className="down" style={{display: "none"}}>
108+
<div ref="down" className="down" style={{display: "none"}}>
98109
{this.state.tests && this.state.tests.map(test=>{
99110
if(test.error){
100111
if(test.stdout.length>0 && test.stderr.length>0) moredetails = <div className="errordetails"> <pre>{test.stdout}<br/>{test.stderr}</pre> </div>

lib/view/index.js

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import Problems from './problems';
55
import config from '../config'
66
import cheerio from 'cheerio'
77
import Play from './play'
8-
// import CodeforcesScraper from './codeforces-scraper';
98

109
function couple(x) {
1110
if(x<10){

lib/view/judge.js

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use babel';
22

33
class Judge {
4-
constructor(){
4+
constructor() {
55
this.ignorewhitespace = true;
66
}
77

8-
clearstring(s){
8+
clearstring(s) {
99
s = s.trim()
1010
s = s.split("\n")
1111
for (var i = 0; i < s.length; i++) {
@@ -14,19 +14,23 @@ class Judge {
1414
return s.join("\n")
1515
}
1616

17-
verify(exp, out){
17+
verify(exp, out, ig) {
1818
exp = this.clearstring(exp)
1919
out = this.clearstring(out)
20+
if(ig){
21+
exp = exp.toUpperCase()
22+
out = out.toUpperCase()
23+
}
2024
return exp == out
2125
}
2226

23-
beautify(err){
27+
beautify(err) {
2428
err = err.trim()
2529
err = err.split("\n")
2630
var tmp = []
2731
for (var i = 1; i < err.length; i++) {
28-
if(err[i].length){
29-
if(err[i].includes("File")){
32+
if (err[i].length) {
33+
if (err[i].includes("File")) {
3034
err[i] = err[i].split(",")[1]
3135
}
3236
tmp.push(err[i].trim())
@@ -35,22 +39,45 @@ class Judge {
3539

3640
var sol = []
3741
for (var i = 0; i < tmp.length; i++) {
38-
if(i&1^1){
42+
if (i & 1 ^ 1) {
3943
sol.push(tmp[i])
40-
}else{
41-
sol[sol.length-1]+=" : " + tmp[i]
44+
} else {
45+
sol[sol.length - 1] += " : " + tmp[i]
4246
}
4347
}
4448

4549
var toreturn = []
4650

47-
for (var i = sol.length-1; i >=0 ; i--) {
51+
for (var i = sol.length - 1; i >= 0; i--) {
4852
toreturn.push(sol[i])
4953
}
5054

5155
return toreturn.join("\n");
5256
}
5357

58+
beautifycpp(err,fname){
59+
const path = require('path');
60+
err = err.trim()
61+
err = err.split("\n")
62+
var tmp = []
63+
for (var i = 1; i < err.length; i++) {
64+
if(err[i].length && err[i].includes("In function")==false){
65+
err[i] = err[i].trim()
66+
var idx = err[i].indexOf(fname)
67+
if(idx==0){
68+
err[i] = err[i].replace(fname,path.basename(fname))
69+
var errarray = err[i].split(":")
70+
if(errarray[2].trim()!="note"){
71+
errarray[1]="Line "+errarray[1]
72+
tmp.push(errarray.slice(1,).join(":").trim())
73+
}
74+
}
75+
}
76+
}
77+
78+
return tmp.join("\n")
79+
}
80+
5481
}
5582

5683
export default new Judge();

lib/view/play.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,10 @@ export default class Play extends React.PureComponent {
6161
fetchimage(){
6262
fetch("https://source.unsplash.com/random/280x280").then(res=>{
6363
this.setState({image: res.url})
64+
this.refs.nextbutton.style.display = "initial";
6465
}).catch(err=> {
6566
this.setState({image: "https://images.unsplash.com/photo-1595496710086-d69bff2ccb19?crop=entropy&cs=tinysrgb&fit=crop&fm=jpg&h=280&ixlib=rb-1.2.1&q=80&w=280"})
67+
this.refs.nextbutton.style.display = "initial";
6668
})
6769
}
6870

@@ -175,7 +177,7 @@ export default class Play extends React.PureComponent {
175177
})
176178
})}
177179
</div>
178-
<button className="nextbutton" onClick={this.reset.bind(this)}>Next</button>
180+
<button ref="nextbutton" className="nextbutton" style={{display: "none"}} onClick={this.reset.bind(this)}>Next</button>
179181
</div>
180182
</div>
181183
)

0 commit comments

Comments
 (0)