Skip to content

Commit 5e716fd

Browse files
authored
Merge pull request #163 from codeitcodes/dev
Update full.html
2 parents 6962ee3 + 648f7e9 commit 5e716fd

20 files changed

+247
-61
lines changed

codedrop.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
function getFileLang(src) {
23

34
var lang_aliases = /*aliases_placeholder[*/ {

filebrowser.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/*
2-
github
3-
*/
41

52
// show bookmark on hover
63
sidebarToggle.addEventListener('mouseover', () => {

full.html

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,27 @@
1313
<meta name="apple-mobile-web-app-title" content="Codeit">
1414

1515
<meta charset="utf-8">
16-
<meta name="description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
17-
16+
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all with friends, family, and the world on Codeit.">
17+
1818
<meta property="og:title" content="Codeit | Mobile code editor connected to Git">
19-
<meta property="og:description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
19+
<meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
2020
<meta property="og:url" content="https://codeit.codes">
2121
<meta property="og:image" content="https://codeit.codes/images/banner-og.png">
22-
<meta property="og:type" content="application">
23-
<meta property="og:site_name" content="Codeit Code Editor">
24-
22+
<meta property="og:type" content="website">
23+
<meta property="og:site_name" content="Codeit">
24+
2525
<meta property="twitter:title" content="Codeit | Mobile code editor connected to Git">
26-
<meta property="twitter:account_id" content="1484271514543345665">
26+
<meta property="twitter:site" content="@codeitcodes">
27+
<meta property="twitter:site:id" content="@codeitcodes">
28+
<meta property="twitter:creator" content="@codeitcodes">
29+
<meta property="twitter:creator:id" content="@codeitcodes">
2730
<meta name="twitter:card" content="summary_large_image">
2831
<meta property="twitter:domain" content="codeit.codes">
29-
<meta property="twitter:url" content="https://codeit.codes">
30-
<meta name="twitter:description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
32+
<meta property="twitter:url" content="https://codeit.codes/">
33+
<meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
3134
<meta name="twitter:image" content="https://codeit.codes/images/banner-og.png">
32-
33-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
34-
<meta name="referrer" content="origin-when-cross-origin">
35+
36+
<meta name="referrer" content="default">
3537
<meta name="keywords" content="code editor, version control tools, source code versioning, source code management tools, python, jquery demo, html, git, how to, bootstrap, jquery, javascript, javascript tutorial, javascript tutorial for beginners, javascript programming, html web form, create form in html, responsive web design, html web design, html design, responsive website development, html5 tutorial, html5 css3, html5 development, web design software, web development software, git tutorial, git howto, git repository, git command, git source code, top programming languages to learn, best programming language, best computer language, open source, open source code, open source applications, source code editor, software development tools, development tool, software developer tools list, programmer tool, web application development software">
3638
<link rel="canonical" href="https://codeit.codes/">
3739
<meta name="next-head-count" content="24">
@@ -40,15 +42,15 @@
4042

4143
<link rel="shortcut icon" href="/icons/android-app-512.png">
4244
<link rel="apple-touch-icon" href="/icons/iphone-app-180.png">
45+
46+
<link rel="apple-touch-startup-image" href="https://codeit.codes/splashes/apple-splash-2048-2732.jpg" media="(orientation: portrait) and (orientation: landscape)">
4347

4448
<link rel="stylesheet" href="/full.css">
4549

46-
<link rel="apple-touch-startup-image" href="https://codeit.codes/splashes/apple-splash-2048-2732.jpg" media="(orientation: portrait) and (orientation: landscape)">
47-
4850
<link rel="preconnect" href="https://codeit.codes">
4951
<link rel="preconnect" href="https://api.github.com" crossorigin>
5052

51-
<link href="/fonts/fonts.css" rel="stylesheet">
53+
<link rel="stylesheet" href="/fonts/fonts.css">
5254

5355
</head>
5456
<body ontouchstart="">

git/gitauth.js

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
/*
2-
github
3-
*/
41

5-
// git login
2+
// github login
63

74
window.onload = async () => {
85

@@ -62,15 +59,17 @@ window.onload = async () => {
6259
}
6360

6461

62+
const authURL = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
63+
6564
loginButton.addEventListener('click', () => {
6665

6766
if (isMobile) {
6867

69-
window.location.href = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
68+
window.location.href = authURL;
7069

7170
} else {
7271

73-
window.open('https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org', 'Login with Github', 'height=575,width=575');
72+
window.open(authURL, 'Login with Github', 'height=575,width=575');
7473

7574
}
7675

@@ -79,35 +78,30 @@ window.onload = async () => {
7978

8079
window.addEventListener('message', (event) => {
8180

82-
// if redirected from git auth
83-
if (event.source.location.pathname === '/git/login') {
84-
85-
// hide intro screen
86-
sidebar.classList.remove('intro');
81+
// hide intro screen
82+
sidebar.classList.remove('intro');
8783

88-
// if on safari, refresh header color
89-
if (isSafari) {
84+
// if on safari, refresh header color
85+
if (isSafari) {
9086

91-
document.querySelector('meta[name="theme-color"]').content = '#313744';
87+
document.querySelector('meta[name="theme-color"]').content = '#313744';
9288

93-
onNextFrame(() => {
89+
onNextFrame(() => {
9490

95-
document.querySelector('meta[name="theme-color"]').content = '#1a1c24';
91+
document.querySelector('meta[name="theme-color"]').content = '#1a1c24';
9692

97-
});
93+
});
9894

99-
}
95+
}
10096

101-
// start loading
102-
startLoading();
97+
// start loading
98+
startLoading();
10399

104-
const gitCode = event.data;
100+
const gitCode = event.data;
105101

106-
// get git token from Github
107-
getGithubToken(gitCode);
102+
// get git token from Github
103+
getGithubToken(gitCode);
108104

109-
}
110-
111105
})
112106

113107

git/gitlab/gitlab-api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
https://gitlab.com/api/v4/projects?access_token=19a48ef34811b9425b6fc1e4c75f1358bdf7f528d151ec5624c46fa61e8b4c03&order_by=updated_at&min_access_level=30
2+
https://docs.gitlab.com/ee/api/oauth2.html
3+
https://docs.gitlab.com/ee/api/projects.html
4+
https://docs.gitlab.com/ee/api/repository_files.html

git/gitlab/gitlab-auth.js

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
2+
// gitlab login
3+
4+
window.onload = async () => {
5+
6+
gitToken = getStorage('gitToken') ?? '';
7+
8+
if (gitToken == 'undefined') {
9+
gitToken = '';
10+
}
11+
12+
13+
// decode URL
14+
linkData = decodeLink(window.location.href);
15+
16+
// clear URL
17+
window.history.pushState(window.location.origin, 'Codeit', window.location.origin + '/full');
18+
19+
20+
// if treeLoc is in local storage
21+
if (linkData.dir) {
22+
23+
treeLoc = linkData.dir;
24+
saveTreeLocLS(treeLoc);
25+
26+
} else {
27+
28+
treeLoc = getStorage('tree') ? getStorage('tree').split(',') : ['', '', ''];
29+
30+
// if repo dosen't have a branch (legacy treeLoc)
31+
if (treeLoc[1] && !treeLoc[1].includes(':')) {
32+
33+
// add default branch to repo
34+
treeLoc[1] += ':main';
35+
saveTreeLocLS(treeLoc);
36+
37+
}
38+
39+
}
40+
41+
42+
if (getStorage('loggedUser')) {
43+
44+
loggedUser = getStorage('loggedUser');
45+
46+
try {
47+
48+
loggedUser = JSON.parse(loggedUser);
49+
50+
// save logged user in local storage
51+
setStorage('loggedUser', loggedUser.login);
52+
53+
} catch(e) {}
54+
55+
} else {
56+
57+
loggedUser = false;
58+
59+
}
60+
61+
62+
const authURL = 'https://gitlab.com/oauth/authorize?client_id=f3b94ba233943fa82855c1b495f28c02ccaa11cf276b419d6d1798488a4bb7b0&redirect_uri=https://codeit.codes/git/gitlab/oauth&response_type=code&state=1f3b3477&scope=api';
63+
64+
loginButton.addEventListener('click', () => {
65+
66+
if (isMobile) {
67+
68+
window.location.href = authURL;
69+
70+
} else {
71+
72+
window.open(authURL, 'Login with Gitlab', 'height=575,width=575');
73+
74+
}
75+
76+
})
77+
78+
79+
window.addEventListener('message', (event) => {
80+
81+
// if redirected from git auth
82+
if (event.source.location.pathname === '/git/gitlab/oauth') {
83+
84+
// hide intro screen
85+
sidebar.classList.remove('intro');
86+
87+
// if on safari, refresh header color
88+
if (isSafari) {
89+
90+
document.querySelector('meta[name="theme-color"]').content = '#313744';
91+
92+
onNextFrame(() => {
93+
94+
document.querySelector('meta[name="theme-color"]').content = '#1a1c24';
95+
96+
});
97+
98+
}
99+
100+
// start loading
101+
startLoading();
102+
103+
const gitCode = event.data;
104+
105+
// get git token from Gitlab
106+
getGitlabToken(gitCode);
107+
108+
}
109+
110+
})
111+
112+
113+
loadLS();
114+
115+
116+
// if git code exists in link
117+
if (linkData.gitCode) {
118+
119+
// hide intro screen
120+
sidebar.classList.remove('intro');
121+
122+
// if on safari, refresh header color
123+
if (isSafari) {
124+
125+
document.querySelector('meta[name="theme-color"]').content = '#313744';
126+
127+
onNextFrame(() => {
128+
129+
document.querySelector('meta[name="theme-color"]').content = '#1a1c24';
130+
131+
});
132+
133+
}
134+
135+
// start loading
136+
startLoading();
137+
138+
const gitCode = linkData.gitCode;
139+
140+
// get git token from Gitlab
141+
getGitlabToken(gitCode);
142+
143+
}
144+
145+
}
146+
147+
async function getGitlabToken(gitCode) {
148+
149+
// post to git with clientId, clientSecret and code
150+
const resp = await axios.post('https://gitlab.com/oauth/token?' +
151+
'client_id=f3b94ba233943fa82855c1b495f28c02ccaa11cf276b419d6d1798488a4bb7b0' +
152+
'&client_secret=1a4098e4770f84f01c94df563201d87b39dae740fe910622c76cd05d8ea30d03' +
153+
'&grant_type=authorization_code&redirect_uri=https://codeit.codes/git/gitlab/oauth' +
154+
'&code=' + gitCode);
155+
156+
// save git token to localStorage
157+
gitToken = resp.access_token;
158+
saveGitTokenLS(gitToken);
159+
160+
161+
// get logged user
162+
loggedUser = await axios.get('https://gitlab.com/api/v4/user', gitToken);
163+
loggedUser = loggedUser.username;
164+
165+
// save logged user in local storage
166+
setStorage('loggedUser', loggedUser);
167+
168+
169+
// render sidebar
170+
renderSidebarHTML();
171+
172+
}
173+
174+
175+
176+
177+
178+
await axios.post('https://gitlab.com/oauth/token?client_id=&client_secret=&code=&&redirect_uri=https://codeit.codes/git/gitlab/oauth')
179+

homepage/privacy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<img class="logo" src="/icons/iphone-app-180.png" width="80" draggable="false" alt="Codeit">
141141
<p class="title">Privacy policy</p>
142142

143-
<div style="display: inline-block;line-height: 1.5;">Codeit dosen't collect data.<br>Your code stays on your device. <br>Codeit uses <a href="https://plausible.io">Plausible</a> to get stats. <br><a href="https://plausible.io/codeit.codes">See the stats.</a></div>
143+
<div style="display: inline-block;line-height: 1.5;">Codeit dosen't collect data.<br>Your code stays on your device. <br>Codeit uses <a href="https://plausible.io">Plausible</a> to get stats. <br><a href="https://plausible.io/codeit.codes?period=all">See the stats.</a></div>
144144
<p style="margin-top: 50px;margin-bottom: 50px;">
145145
<a href="/" style="color: inherit;">- ❤️ Codeit team</a>
146146
</p>

index.html

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,38 +14,40 @@
1414
<meta name="apple-mobile-web-app-title" content="Codeit">
1515

1616
<meta charset="utf-8">
17-
<meta name="description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
17+
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all with friends, family, and the world on Codeit.">
1818

1919
<meta property="og:title" content="Codeit | Mobile code editor connected to Git">
20-
<meta property="og:description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
20+
<meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
2121
<meta property="og:url" content="https://codeit.codes">
2222
<meta property="og:image" content="https://codeit.codes/images/banner-og.png">
23-
<meta property="og:type" content="application">
24-
<meta property="og:site_name" content="Codeit Code Editor">
23+
<meta property="og:type" content="website">
24+
<meta property="og:site_name" content="Codeit">
2525

2626
<meta property="twitter:title" content="Codeit | Mobile code editor connected to Git">
27-
<meta property="twitter:account_id" content="1484271514543345665">
27+
<meta property="twitter:site" content="@codeitcodes">
28+
<meta property="twitter:site:id" content="@codeitcodes">
29+
<meta property="twitter:creator" content="@codeitcodes">
30+
<meta property="twitter:creator:id" content="@codeitcodes">
2831
<meta name="twitter:card" content="summary_large_image">
2932
<meta property="twitter:domain" content="codeit.codes">
30-
<meta property="twitter:url" content="https://codeit.codes">
31-
<meta name="twitter:description" content="Codeit runs on the web, open source, and free. Supports HTML, CSS, JavaScript, Python, Bootstrap, XML and more. Easy to use without how to.">
33+
<meta property="twitter:url" content="https://codeit.codes/">
34+
<meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
3235
<meta name="twitter:image" content="https://codeit.codes/images/banner-og.png">
3336

34-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
35-
<meta name="referrer" content="origin-when-cross-origin">
37+
<meta name="referrer" content="default">
3638
<meta name="keywords" content="code editor, version control tools, source code versioning, source code management tools, python, jquery demo, html, git, how to, bootstrap, jquery, javascript, javascript tutorial, javascript tutorial for beginners, javascript programming, html web form, create form in html, responsive web design, html web design, html design, responsive website development, html5 tutorial, html5 css3, html5 development, web design software, web development software, git tutorial, git howto, git repository, git command, git source code, top programming languages to learn, best programming language, best computer language, open source, open source code, open source applications, source code editor, software development tools, development tool, software developer tools list, programmer tool, web application development software">
3739
<link rel="canonical" href="https://codeit.codes/">
3840
<meta name="next-head-count" content="24">
3941
<meta name="robots" content="all">
40-
<script nonce>if (top !== window) { top.location.href = 'https://codeit.codes/' }</script>
42+
<script>if (top !== window) { window.location.href = '/redirect' }</script>
4143
<script defer data-domain="codeit.codes" src="https://plausible.io/js/plausible.js"></script>
4244

4345
<link rel="shortcut icon" href="/icons/android-app-512.png">
4446
<link rel="apple-touch-icon" href="/icons/iphone-app-180.png">
45-
46-
<link rel="stylesheet" href="/homepage/homepage.css">
4747

4848
<link rel="apple-touch-startup-image" href="https://codeit.codes/splashes/apple-splash-2048-2732.jpg" media="(orientation: portrait) and (orientation: landscape)">
49+
50+
<link rel="stylesheet" href="/homepage/homepage.css">
4951

5052
</head>
5153

0 commit comments

Comments
 (0)