Skip to content

Commit b320971

Browse files
committed
deploy: 606b7d0
1 parent c707957 commit b320971

File tree

93 files changed

+1896
-596
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1896
-596
lines changed

appConfig.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ window.AppConfig = {
2626
"app_notification_url": "assets/notifications/dev/",
2727
"app_update_url": "https://updates.phcode.io/tauri/update-latest-experimental-build.json",
2828
"linting.enabled_by_default": true,
29-
"build_timestamp": "2025-01-12T12:32:17.861Z",
29+
"build_timestamp": "2025-01-14T03:05:33.523Z",
3030
"googleAnalyticsID": "G-P4HJFPDB76",
3131
"googleAnalyticsIDDesktop": "G-VE5BXWJ0HF",
3232
"mixPanelID": "49c4d164b592be2350fc7af06a259bf3",
@@ -38,7 +38,7 @@ window.AppConfig = {
3838
"bugsnagEnv": "development"
3939
},
4040
"name": "Phoenix Code",
41-
"version": "4.0.0-20797",
41+
"version": "4.0.0-20800",
4242
"apiVersion": "4.0.0",
4343
"homepage": "https://core.ai",
4444
"issues": {

assets/default-project/en.zip

0 Bytes
Binary file not shown.

assets/new-project/assets/css/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,12 @@ img {
909909
margin-bottom: 30px;
910910
}
911911

912+
.project-bottom {
913+
border-top: 3px solid rgba(255, 255, 255, 0.1);
914+
padding-top: 20px;
915+
margin-top: auto;
916+
}
917+
912918
.new-project-content {
913919
overflow-y: auto;
914920
}

assets/new-project/assets/js/code-editor.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,6 @@ function initCodeEditor() {
204204
_openURLInTauri(document.getElementById(iconID).getAttribute('href'));
205205
};
206206
}
207-
if(window.top.__TAURI__) {
208-
// in desktop, we don't show github project option till we have git extension integrated.
209-
document.getElementById("newGitHubProject").classList.add("forced-hidden");
210-
}
211207
document.getElementById("newGitHubProject").onclick = function() {
212208
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "main.Click", "github-project");
213209
window.location.href = 'new-project-github.html';
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
* GNU AGPL-3.0 License
3+
*
4+
* Copyright (c) 2021 - present core.ai . All rights reserved.
5+
*
6+
* This program is free software: you can redistribute it and/or modify it
7+
* under the terms of the GNU Affero General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
14+
* for more details.
15+
*
16+
* You should have received a copy of the GNU Affero General Public License
17+
* along with this program. If not, see https://opensource.org/licenses/AGPL-3.0.
18+
*
19+
*/
20+
21+
/*global newProjectExtension, Strings, Metrics*/
22+
/*eslint no-console: 0*/
23+
/*eslint strict: ["error", "global"]*/
24+
/* jshint ignore:start */
25+
26+
function desktopInit() {
27+
const LAST_GIT_CLONE_BASE_DIR = "PH_LAST_GIT_CLONE_BASE_DIR";
28+
let createProjectBtn, websiteURLInput, locationInput;
29+
30+
function _validateGitURL(errors) {
31+
let gitURL = websiteURLInput.value;
32+
if(gitURL){
33+
$(websiteURLInput).removeClass("error-border");
34+
return true;
35+
}
36+
$(websiteURLInput).addClass("error-border");
37+
errors.push(`<span><i class="fas fa-exclamation-triangle" style="color: #f89406"></i>&nbsp;&nbsp;${Strings.ERROR_GIT_URL_INVALID}</span>`);
38+
return false;
39+
}
40+
41+
function _validateProjectLocation(errors) {
42+
let location = locationInput.value;
43+
if( location === Strings.PLEASE_SELECT_A_FOLDER){
44+
$(locationInput).addClass("error-border");
45+
return false;
46+
}
47+
if(locationInput.error){
48+
errors.push(`<span><i class="fas fa-exclamation-triangle" style="color: #f89406"></i>&nbsp;&nbsp;${locationInput.error}</span>`);
49+
$(locationInput).addClass("error-border");
50+
return false;
51+
}
52+
$(locationInput).removeClass("error-border");
53+
return true;
54+
}
55+
56+
function _validate() {
57+
const errors = [];
58+
let isValid = _validateGitURL(errors);
59+
isValid = _validateProjectLocation(errors) && isValid;
60+
$(createProjectBtn).prop('disabled', !isValid);
61+
const $messageDisplay = $("#messageDisplay");
62+
$messageDisplay.html("");
63+
if(!isValid) {
64+
$messageDisplay.html(errors.join("<br>"));
65+
}
66+
return isValid;
67+
}
68+
69+
async function _deduceClonePath(newPath) {
70+
if(!newPath){
71+
newPath = locationInput.originalPath;
72+
}
73+
if(!newPath){
74+
return;
75+
}
76+
const {clonePath, error} = await newProjectExtension.getGitCloneDir(newPath, websiteURLInput.value);
77+
locationInput.clonePath = clonePath;
78+
locationInput.value = window.top.Phoenix.fs.getTauriPlatformPath(clonePath);
79+
locationInput.error = error;
80+
locationInput.originalPath = newPath;
81+
}
82+
83+
function _selectFolder() {
84+
newProjectExtension.showFolderSelect(locationInput.originalPath || "")
85+
.then((newPath)=>{
86+
_deduceClonePath(newPath).then(_validate);
87+
}).catch((err)=>{
88+
console.error("user cancelled or error", err);
89+
});
90+
}
91+
92+
function _createProjectClicked() {
93+
localStorage.setItem(LAST_GIT_CLONE_BASE_DIR, locationInput.originalPath);
94+
newProjectExtension.gitClone(websiteURLInput.value, locationInput.clonePath);
95+
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "git.Click", "create");
96+
newProjectExtension.closeDialogue();
97+
}
98+
99+
function initGitProject() {
100+
$(".label-clone").text(Strings.GIT_CLONE_URL);
101+
createProjectBtn = document.getElementById("createProjectBtn");
102+
websiteURLInput = document.getElementById("websiteURLInput");
103+
locationInput = document.getElementById("locationInput");
104+
createProjectBtn.onclick = _createProjectClicked;
105+
$(websiteURLInput).keyup(()=>{
106+
_deduceClonePath().then(_validate);
107+
});
108+
locationInput.value = Strings.PLEASE_SELECT_A_FOLDER;
109+
locationInput.onclick = _selectFolder;
110+
websiteURLInput.value = "https://github.com/phcode-dev/HTML-Starter-Templates.git";
111+
_deduceClonePath(localStorage.getItem(LAST_GIT_CLONE_BASE_DIR)).then(_validate);
112+
}
113+
window.initGitProject = initGitProject;
114+
}
115+
116+
if(window.top.Phoenix.isNativeApp){
117+
desktopInit();
118+
}

assets/new-project/assets/js/new-github-project.js

Lines changed: 107 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -23,115 +23,127 @@
2323
/*eslint strict: ["error", "global"]*/
2424
/* jshint ignore:start */
2525

26-
let createProjectBtn, websiteURLInput, locationInput;
27-
const FLATTEN_ZIP_FIRST_LEVEL_DIR = true;
26+
function browserInit() {
27+
let createProjectBtn, websiteURLInput, locationInput;
28+
const FLATTEN_ZIP_FIRST_LEVEL_DIR = true;
2829

29-
function _isValidGitHubURL(url) {
30-
// strip trailing slash
31-
url = url.replace(/\/$/, "");
32-
let githubPrefix = "https://github.com/";
33-
let components = url.replace("https://github.com/", '').split('/');
34-
if(!url.startsWith(githubPrefix) || components.length !== 2){
35-
return false;
30+
function _isValidGitHubURL(url) {
31+
// strip trailing slash
32+
url = url.replace(/\/$/, "");
33+
let githubPrefix = "https://github.com/";
34+
let components = url.replace("https://github.com/", '').split('/');
35+
if(!url.startsWith(githubPrefix) || components.length !== 2){
36+
return false;
37+
}
38+
return true;
3639
}
37-
return true;
38-
}
3940

40-
function _fixGitHubBrokenURL() {
41-
let githubPrefix = "https://github.com/",
42-
gitSuffix = '.git';
43-
let githubURL = websiteURLInput.value;
44-
if(githubURL.startsWith("http:")){
45-
githubURL = githubURL.replace("http:", "https:");
46-
}
47-
if(!githubURL.startsWith(githubPrefix)){
48-
return;
49-
}
50-
// strip any query string params if present
51-
let queryParamTrimIndex = githubURL.indexOf('?') >= 0 ? githubURL.indexOf('?') : githubURL.length;
52-
githubURL = githubURL.substring(0, queryParamTrimIndex);
53-
// trim everything after https://github.com/orgname/repo/... to https://github.com/orgname/repo
54-
let components = githubURL.replace("https://github.com/", '').split('/');
55-
// trim .git at the end of the name
56-
if(githubURL.endsWith(gitSuffix)){
57-
githubURL = githubURL.replace(new RegExp(gitSuffix + '$'), '');
58-
}
59-
if(components.length > 2){
60-
githubURL = `https://github.com/${components[0]}/${components[1]}`;
41+
function _fixGitHubBrokenURL() {
42+
let githubPrefix = "https://github.com/",
43+
gitSuffix = '.git';
44+
let githubURL = websiteURLInput.value;
45+
if(githubURL.startsWith("http:")){
46+
githubURL = githubURL.replace("http:", "https:");
47+
}
48+
if(!githubURL.startsWith(githubPrefix)){
49+
return;
50+
}
51+
// strip any query string params if present
52+
let queryParamTrimIndex = githubURL.indexOf('?') >= 0 ? githubURL.indexOf('?') : githubURL.length;
53+
githubURL = githubURL.substring(0, queryParamTrimIndex);
54+
// trim everything after https://github.com/orgname/repo/... to https://github.com/orgname/repo
55+
let components = githubURL.replace("https://github.com/", '').split('/');
56+
// trim .git at the end of the name
57+
if(githubURL.endsWith(gitSuffix)){
58+
githubURL = githubURL.replace(new RegExp(gitSuffix + '$'), '');
59+
}
60+
if(components.length > 2){
61+
githubURL = `https://github.com/${components[0]}/${components[1]}`;
62+
}
63+
websiteURLInput.value = githubURL;
6164
}
62-
websiteURLInput.value = githubURL;
63-
}
6465

65-
function _validateGitHubURL() {
66-
_fixGitHubBrokenURL();
67-
let githubURL = websiteURLInput.value;
68-
if(_isValidGitHubURL(githubURL)){
69-
$(websiteURLInput).removeClass("error-border");
70-
return true;
66+
function _validateGitHubURL() {
67+
_fixGitHubBrokenURL();
68+
let githubURL = websiteURLInput.value;
69+
const $messageDisplay = $("#messageDisplay");
70+
if(_isValidGitHubURL(githubURL)){
71+
$(websiteURLInput).removeClass("error-border");
72+
$messageDisplay.html("");
73+
return true;
74+
}
75+
$(websiteURLInput).addClass("error-border");
76+
$messageDisplay.html(`<span><i class="fas fa-exclamation-triangle" style="color: #f89406"></i>&nbsp;&nbsp;${Strings.ERROR_ONLY_GITHUB}</span>`);
77+
return false;
7178
}
72-
$(websiteURLInput).addClass("error-border");
73-
return false;
74-
}
7579

76-
function _validateProjectLocation() {
77-
if(!window.showDirectoryPicker){
78-
// fs access apis not present, so we will give phoenix empty location to figure out a suitable location
80+
function _validateProjectLocation() {
81+
if(!window.showDirectoryPicker){
82+
// fs access apis not present, so we will give phoenix empty location to figure out a suitable location
83+
return true;
84+
}
85+
let location = locationInput.value;
86+
if( location === Strings.PLEASE_SELECT_A_FOLDER){
87+
$(locationInput).addClass("error-border");
88+
return false;
89+
}
90+
$(locationInput).removeClass("error-border");
7991
return true;
8092
}
81-
let location = locationInput.value;
82-
if( location === Strings.PLEASE_SELECT_A_FOLDER){
83-
$(locationInput).addClass("error-border");
84-
return false;
93+
94+
function _validate() {
95+
return _validateGitHubURL()
96+
&& _validateProjectLocation();
8597
}
86-
$(locationInput).removeClass("error-border");
87-
return true;
88-
}
8998

90-
function _validate() {
91-
return _validateGitHubURL()
92-
&& _validateProjectLocation();
93-
}
99+
function _selectFolder() {
100+
newProjectExtension.showFolderSelect()
101+
.then(file =>{
102+
locationInput.fullPath = file;
103+
locationInput.value = file.replace(newProjectExtension.getMountDir(), "");
104+
_validateProjectLocation();
105+
});
106+
}
94107

95-
function _selectFolder() {
96-
newProjectExtension.showFolderSelect()
97-
.then(file =>{
98-
locationInput.fullPath = file;
99-
locationInput.value = file.replace(newProjectExtension.getMountDir(), "");
100-
_validateProjectLocation();
101-
});
102-
}
108+
function _createProjectClicked() {
109+
if(_validate()){
110+
let githubURL = websiteURLInput.value;
111+
let components = githubURL.replace("https://github.com/", '').split('/');
112+
let zipURL = `https://phcode.site/getGitHubZip?org=${components[0]}&repo=${components[1]}`;
113+
let suggestedProjectName = `${components[0]}-${components[1]}`;
114+
newProjectExtension.downloadAndOpenProject(
115+
zipURL,
116+
locationInput.fullPath, suggestedProjectName, FLATTEN_ZIP_FIRST_LEVEL_DIR)
117+
.then(()=>{
118+
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "github.Click", "create.success");
119+
newProjectExtension.closeDialogue();
120+
});
121+
} else {
122+
newProjectExtension.showErrorDialogue(
123+
Strings.MISSING_FIELDS,
124+
Strings.PLEASE_FILL_ALL_REQUIRED);
125+
}
126+
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "github.Click", "create");
127+
}
103128

104-
function _createProjectClicked() {
105-
if(_validate()){
106-
let githubURL = websiteURLInput.value;
107-
let components = githubURL.replace("https://github.com/", '').split('/');
108-
let zipURL = `https://phcode.site/getGitHubZip?org=${components[0]}&repo=${components[1]}`;
109-
let suggestedProjectName = `${components[0]}-${components[1]}`;
110-
newProjectExtension.downloadAndOpenProject(
111-
zipURL,
112-
locationInput.fullPath, suggestedProjectName, FLATTEN_ZIP_FIRST_LEVEL_DIR)
113-
.then(()=>{
114-
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "github.Click", "create.success");
115-
newProjectExtension.closeDialogue();
116-
});
117-
} else {
118-
newProjectExtension.showErrorDialogue(
119-
Strings.MISSING_FIELDS,
120-
Strings.PLEASE_FILL_ALL_REQUIRED);
129+
function initGitProject() {
130+
if(!window.showDirectoryPicker){ // fs access apis not present
131+
$(document.getElementById("projectLocation")).addClass("forced-hidden");
132+
}
133+
$(".label-clone").text(Strings.GIT_REPO_URL);
134+
createProjectBtn = document.getElementById("createProjectBtn");
135+
websiteURLInput = document.getElementById("websiteURLInput");
136+
locationInput = document.getElementById("locationInput");
137+
createProjectBtn.onclick = _createProjectClicked;
138+
$(websiteURLInput).keyup(_validate);
139+
locationInput.value = Strings.PLEASE_SELECT_A_FOLDER;
140+
locationInput.onclick = _selectFolder;
141+
websiteURLInput.value = "https://github.com/phcode-dev/HTML-Starter-Templates";
142+
_validate();
121143
}
122-
Metrics.countEvent(Metrics.EVENT_TYPE.NEW_PROJECT, "github.Click", "create");
144+
window.initGitProject = initGitProject;
123145
}
124146

125-
function initGithubProject() {
126-
if(!window.showDirectoryPicker){ // fs access apis not present
127-
$(document.getElementById("projectLocation")).addClass("forced-hidden");
128-
}
129-
createProjectBtn = document.getElementById("createProjectBtn");
130-
websiteURLInput = document.getElementById("websiteURLInput");
131-
locationInput = document.getElementById("locationInput");
132-
createProjectBtn.onclick = _createProjectClicked;
133-
$(websiteURLInput).keyup(_validate);
134-
locationInput.value = Strings.PLEASE_SELECT_A_FOLDER;
135-
locationInput.onclick = _selectFolder;
136-
_validate();
147+
if(!window.top.Phoenix.isNativeApp){
148+
browserInit();
137149
}

assets/new-project/code-editor.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ <h4 class="tab-title mb-0 localize">{{START_PROJECT}}</h4>
124124
</li>
125125
<li>
126126
<a id="newGitHubProject" href="#" class="tabable" tabindex="5">
127-
<img src="images/tab-img7.png" alt="image">
128-
<span class="localize">{{GITHUB_PROJECT}}</span>
127+
<img src="images/git.svg" alt="image">
128+
<span class="localize">{{GIT_PROJECT}}</span>
129129
</a>
130130
</li>
131131
<!-- <li>-->

assets/new-project/images/git.svg

Lines changed: 4 additions & 0 deletions
Loading
-1.17 KB
Binary file not shown.

0 commit comments

Comments
 (0)