Skip to content

Commit 6797861

Browse files
authored
Twitter Embeds
Twitter Embeds
2 parents 1a3e05f + fdfe870 commit 6797861

File tree

9 files changed

+197
-75
lines changed

9 files changed

+197
-75
lines changed

api/link.js

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,37 @@ const html = `
5555
<meta name="apple-mobile-web-app-status-bar-style" content="#313744">
5656
<meta name="apple-mobile-web-app-title" content="Codeit">
5757
58-
<meta http-equiv="origin-trial" content="At6bIDqQqUBcNVY46zIFOhsfQekTjYXogHK35lCdfrpna6/wqhxQsIh+kfTDRcLVPP0jyfFX5gTbBM4trLnn4g0AAABqeyJvcmlnaW4iOiJodHRwczovL2NvZGVpdC5jb2Rlczo0NDMiLCJmZWF0dXJlIjoiV2ViQXBwVXJsSGFuZGxpbmciLCJleHBpcnkiOjE2NDMxNTUxOTksImlzU3ViZG9tYWluIjp0cnVlfQ==">
59-
6058
<meta charset="utf-8">
61-
<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.">
59+
<!-- <meta name="description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
6260
6361
<meta property="og:title" content="`+ title +`">
64-
<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.">
62+
<!-- <meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
6563
<meta property="og:url" content="https://codeit.codes">
6664
<meta property="og:image" content="https://codeit.codes/images/banner-og.png">
67-
<meta property="og:type" content="application">
68-
<meta property="og:site_name" content="Codeit Code Editor">
65+
<meta property="og:type" content="website">
66+
<meta property="og:site_name" content="Codeit">
6967
7068
<meta property="twitter:title" content="`+ title +`">
71-
<meta property="twitter:account_id" content="1484271514543345665">
72-
<meta name="twitter:card" content="summary">
73-
<meta property="twitter:domain" content="codeit.codes">
74-
<meta property="twitter:url" content="https://codeit.codes">
75-
<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.">
69+
<meta property="twitter:site" content="@codeitcodes">
70+
<meta name="twitter:card" content="player">
71+
<meta property="twitter:domain" content="https://codeit.codes/">
72+
<!-- <meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit."> -->
7673
<meta name="twitter:image" content="https://codeit.codes/images/banner-og.png">
74+
<meta name="twitter:player" content="https://codeit.codes/api/link?url=`+ query.url +`">
75+
<meta name="twitter:player:stream:content_type" content="text/html">
76+
<meta name="twitter:player:width" content="800">
77+
<meta name="twitter:player:height" content="600">
7778
78-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
79-
<meta name="referrer" content="origin-when-cross-origin">
79+
<meta name="referrer" content="default">
8080
<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">
8181
<link rel="canonical" href="https://codeit.codes/">
8282
<meta name="next-head-count" content="24">
8383
<meta name="robots" content="all">
8484
85+
<link rel="iframely player" type="text/html"
86+
href="https://codeit.codes/api/link?url=`+ query.url +`"
87+
media="(aspect-ratio: 1280/720)"/>
88+
8589
<link rel="shortcut icon" href="https://codeit.codes/icons/android-app-512.png">
8690
<link rel="apple-touch-icon" href="https://codeit.codes/icons/iphone-app-180.png">
8791
@@ -94,7 +98,7 @@ const html = `
9498
const url = new URL(window.location.href).searchParams;
9599
96100
let link = url.get('url');
97-
let embed = url.get('embed');
101+
let oembed = url.get('oembed');
98102
99103
const isDev = (window.location.hostname === 'dev.codeit.codes');
100104
@@ -114,7 +118,7 @@ const html = `
114118
115119
if (link) {
116120
117-
if (embed) link += '?embed=true';
121+
if (oembed) link += '?oembed=true';
118122
119123
const resp = decodeLink(link);
120124

api/oembed.js

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ export default function handler(request, response) {
33

44
const query = request.query;
55

6-
let json = { "error": "Try adding a URL" };
6+
const isJSON = query.format ? query.format.toLowerCase() === 'json' : false;
7+
8+
9+
let resp;
10+
11+
if (isJSON) resp = { "error": "Try adding a URL" };
12+
else resp = 'Try adding a <code>?url=</code>.';
13+
714

815
if (query.url) {
916

@@ -13,23 +20,42 @@ export default function handler(request, response) {
1320
url = 'https://dev.codeit.codes';
1421
}
1522

16-
const embedHTML = `<iframe src="`+ url +`/api/link?url=`+ query.url +`&embed=true" width="700" height="480" style="border-radius: 10px;" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe></html>`;
23+
url += '/api/link?url=' + query.url + '&oembed=true';
1724

18-
json = {
19-
"type": "rich",
20-
"title": "Codeit",
21-
"width": 700,
22-
"height": 480,
23-
"html": embedHTML,
24-
"version": "1.0",
25-
"cache_age": 3600,
26-
"provider_name": "Codeit",
27-
"provider_url": "https://codeit.codes/"
28-
};
25+
const embedHTML = `<iframe src="`+ url +`" width="700" height="480" style="border-radius: 10px;" allow="accelerometer; camera; encrypted-media; display-capture; geolocation; gyroscope; microphone; midi; clipboard-read; clipboard-write" allowfullscreen="true" allowpaymentrequest="true" loading="lazy" sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation allow-same-origin allow-scripts allow-top-navigation-by-user-activation" scrolling="yes" frameborder="0"></iframe></html>`;
2926

30-
}
3127

32-
response.status(200).json(json);
28+
if (isJSON) {
29+
30+
resp = {
31+
"type": "rich",
32+
"title": "Codeit",
33+
"width": 700,
34+
"height": 480,
35+
"html": embedHTML,
36+
"version": "1.0",
37+
"cache_age": 3600,
38+
"provider_name": "Codeit",
39+
"provider_url": "https://codeit.codes/"
40+
};
41+
42+
} else {
43+
44+
resp = `
45+
<oembed>
46+
<html>`+ embedHTML +`</html>
47+
<width>700</width>
48+
<height>480</height>
49+
</oembed>
50+
`;
51+
52+
}
53+
54+
}
55+
56+
57+
if (isJSON) response.status(200).json(resp);
58+
else response.status(200).send(resp);
3359

3460
}
3561

filebrowser.js

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -859,44 +859,6 @@ function addHTMLItemListeners() {
859859
}
860860

861861
})
862-
863-
// if item is a file
864-
if (item.classList.contains('file')
865-
&& item.querySelector('.push-wrapper')) {
866-
867-
item.querySelector('.push-wrapper')
868-
.addEventListener('contextmenu', () => {
869-
870-
let commitMessage;
871-
872-
// get selected branch
873-
let selBranch = treeLoc[1].split(':')[1];
874-
875-
// open push screen
876-
commitMessage = prompt('Push \''+ item.innerText + (selBranch ? '\' to branch \'' + selBranch + '\'?' : '\'?'),
877-
'Type push description...');
878-
879-
// if canceled push, return
880-
if (!commitMessage) return;
881-
882-
// if not specified message
883-
if (commitMessage === 'Type push description...') {
884-
885-
// show default message
886-
commitMessage = 'Update ' + item.innerText;
887-
888-
}
889-
890-
891-
// play push animation
892-
playPushAnimation(item.querySelector('.push-wrapper'));
893-
894-
// push file
895-
pushFileFromHTML(item, commitMessage);
896-
897-
})
898-
899-
}
900862

901863
})
902864

@@ -927,6 +889,34 @@ function clickedOnFileHTML(fileEl, event) {
927889

928890
} else {
929891

892+
/*
893+
// if not logged in to git
894+
if (gitToken == '') {
895+
896+
function openLogin() {
897+
898+
const authURL = 'https://github.com/login/oauth/authorize?client_id=7ede3eed3185e59c042d&scope=repo,user,write:org';
899+
900+
if (isMobile) {
901+
902+
window.location.href = authURL;
903+
904+
} else {
905+
906+
window.open(authURL, 'Login with Github', 'height=575,width=575');
907+
908+
}
909+
910+
}
911+
912+
showDialog(openLogin, 'Login to save this file.', 'Login');
913+
914+
return;
915+
916+
}
917+
*/
918+
919+
930920
let commitMessage;
931921

932922
// if ctrl/meta/shift-clicked on push button

full.css

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,69 @@ body.mobile .menu .icon a {
16801680
}
16811681

16821682

1683+
.dialog {
1684+
position: fixed;
1685+
background: var(--deep-midnight-blue);
1686+
color: #dcddde;
1687+
box-shadow: 0 8px 16px rgb(0 0 0 / 24%);
1688+
border-radius: 11.5px;
1689+
line-height: 1.5;
1690+
max-width: 200px;
1691+
width: 194px;
1692+
top: 50%;
1693+
left: calc((var(--sidebar-width) - 1px) / 2);
1694+
opacity: 0;
1695+
padding: 2px;
1696+
transform: translate(-50%, -50%) scale(0.94);
1697+
will-change: transform;
1698+
transition: 0s .18s, .18s var(--bounce-function) opacity;
1699+
pointer-events: none;
1700+
z-index: 1000;
1701+
}
1702+
1703+
.dialog.visible {
1704+
opacity: 1;
1705+
padding: 7px;
1706+
transform: translate(-50%, -50%) scale(1);
1707+
transition: .18s var(--bounce-function);
1708+
pointer-events: auto;
1709+
}
1710+
1711+
.dialog .title {
1712+
padding: 8px 14px;
1713+
}
1714+
1715+
.dialog .button-wrapper {
1716+
display: flex;
1717+
margin-top: 7px;
1718+
}
1719+
1720+
.dialog .button {
1721+
padding: 8px 14px;
1722+
border-radius: 5.75px;
1723+
display: flex;
1724+
justify-content: center;
1725+
width: 50%;
1726+
}
1727+
1728+
.dialog .cancel {
1729+
color: hsl(228deg 16% 37%);
1730+
}
1731+
1732+
.dialog .confirm {
1733+
color: var(--rosemary-lighter);
1734+
font-weight: 500;
1735+
}
1736+
1737+
.dialog .button:active {
1738+
background: rgba(255,255,255,0.1);
1739+
}
1740+
1741+
body:not(.mobile) .dialog .button:not(:active):hover {
1742+
background: rgba(255,255,255,0.05);
1743+
}
1744+
1745+
16831746
.message-wrapper {
16841747
position: fixed;
16851748
left: 0;

full.html

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

1515
<meta charset="utf-8">
16-
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all with friends, family, and the world on Codeit.">
16+
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
1717

1818
<meta property="og:title" content="Codeit | Mobile code editor connected to Git">
1919
<meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
@@ -27,7 +27,7 @@
2727
<meta property="twitter:site:id" content="@codeitcodes">
2828
<meta property="twitter:creator" content="@codeitcodes">
2929
<meta property="twitter:creator:id" content="@codeitcodes">
30-
<meta name="twitter:card" content="summary_large_image">
30+
<meta name="twitter:card" content="summary">
3131
<meta property="twitter:domain" content="codeit.codes">
3232
<meta property="twitter:url" content="https://codeit.codes/">
3333
<meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
@@ -224,6 +224,14 @@
224224

225225
<div class="menu branch-menu"></div>
226226

227+
<div class="dialog">
228+
<div class="title"></div>
229+
<div class="button-wrapper">
230+
<div class="cancel button">Cancel</div>
231+
<div class="confirm button">Confirm</div>
232+
</div>
233+
</div>
234+
227235
<div class="message-wrapper">
228236
<div class="message"></div>
229237
</div>

index.html

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

1616
<meta charset="utf-8">
17-
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all with friends, family, and the world on Codeit.">
17+
<meta name="description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
1818

1919
<meta property="og:title" content="Codeit | Mobile code editor connected to Git">
2020
<meta property="og:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">
@@ -28,7 +28,7 @@
2828
<meta property="twitter:site:id" content="@codeitcodes">
2929
<meta property="twitter:creator" content="@codeitcodes">
3030
<meta property="twitter:creator:id" content="@codeitcodes">
31-
<meta name="twitter:card" content="summary_large_image">
31+
<meta name="twitter:card" content="summary">
3232
<meta property="twitter:domain" content="codeit.codes">
3333
<meta property="twitter:url" content="https://codeit.codes/">
3434
<meta name="twitter:description" content="Run JavaScript projects, code your ideas, and share it all on Codeit.">

utils.js

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ const body = document.body,
6060
learnClose = learnWrapper.querySelector('.close'),
6161

6262
branchMenu = document.querySelector('.branch-menu'),
63+
64+
dialog = document.querySelector('.dialog'),
65+
dialogTitle = dialog.querySelector('.title'),
66+
dialogCancel = dialog.querySelector('.cancel'),
67+
dialogConfirm = dialog.querySelector('.confirm'),
6368

6469
messageEl = document.querySelector('.message'),
6570

@@ -68,7 +73,7 @@ const body = document.body,
6873

6974

7075
// version
71-
const version = '3.2.0';
76+
const version = '3.2.5';
7277
versionEl.innerText = version;
7378

7479
let logVersion = () => {
@@ -143,6 +148,32 @@ function showMessage(message, duration) {
143148

144149

145150

151+
// show dialog
152+
153+
function showDialog(confirmHandler, titleText, confirmText) {
154+
155+
// add dialog text to HTML
156+
dialogTitle.textContent = titleText;
157+
dialogConfirm.textContent = confirmText;
158+
159+
// show dialog
160+
dialog.classList.add('visible');
161+
162+
// add confirm button listener
163+
dialogConfirm.onclick = confirmHandler;
164+
165+
}
166+
167+
// add cancel button listener
168+
dialogCancel.addEventListener('click', () => {
169+
170+
// hide dialog
171+
dialog.classList.remove('visible');
172+
173+
});
174+
175+
176+
146177
// device and platform queries
147178

148179
let isMobile = false;

0 commit comments

Comments
 (0)