Skip to content

Commit

Permalink
Zip plugin: Skip not found files when zipping
Browse files Browse the repository at this point in the history
  • Loading branch information
givanz committed Jul 26, 2023
1 parent 60d2a11 commit 44f439c
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 10 deletions.
40 changes: 40 additions & 0 deletions .github/lock.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads

# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 365

# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). Set to `false` to disable
skipCreatedBefore: false

# Issues and pull requests with these labels will be ignored. Set to `[]` to disable
exemptLabels:
- no-locking
- help-wanted

# Label to add before locking, such as `outdated`. Set to `false` to disable
lockLabel: outdated

# Comment to post before locking. Set to `false` to disable
lockComment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.
# Assign `resolved` as the reason for locking. Set to `false` to disable
setLockReason: true

# Limit to only `issues` or `pulls`
# only: issues

# Optionally, specify configuration settings just for `issues` or `pulls`
# issues:
# exemptLabels:
# - help-wanted
# lockLabel: outdated

# pulls:
# daysUntilLock: 30

# Repository to extend settings from
# _extends: repo
13 changes: 13 additions & 0 deletions .github/no-response.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Configuration for probot-no-response - https://github.com/probot/no-response

# Number of days of inactivity before an Issue is closed for lack of response
daysUntilClose: 10
# Label requiring a response
responseRequiredLabel: more-information-needed
# Comment to post when closing an Issue for lack of response. Set to `false` to disable
closeComment: >
This issue has been automatically closed because there has been no response
to our request for more information from the original author. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further.
4 changes: 4 additions & 0 deletions libs/builder/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -2989,6 +2989,10 @@ Vvveb.FileManager = {
return this.pages[this.currentPage]['url'];
}
},

getCurrentPage: function() {
return this.currentPage;
},

getPageData: function(key) {
if (this.currentPage) {
Expand Down
38 changes: 31 additions & 7 deletions libs/builder/plugin-jszip.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ function () {
let binary = asset.binary;

let filename = href.substring(href.lastIndexOf('/')+1);

let path = href.substring(0, href.lastIndexOf('/')).replace(/\.\.\//g, "");
if (href.indexOf("://") > 0) {
//ignore path for external assets
path = "";
}

promises.push(new Promise((resolve, reject) => {

let request = new XMLHttpRequest();
Expand All @@ -65,9 +70,11 @@ function () {

request.onload = function() {
if (request.status === 200) {
resolve({url, href, filename, binary, data:request.response});
resolve({url, href, filename, path, binary, data:request.response, status:request.status});
} else {
reject(Error('Error code:' + request.statusText));
//reject(Error('Error code:' + request.statusText));
console.error('Error code:' + request.statusText);
resolve({status:request.status});
}
};

Expand All @@ -76,7 +83,11 @@ function () {
};

// Send the request
request.send();
try {
request.send();
} catch (error) {
console.error(error);
}
/*
$.ajax({
url: url,
Expand All @@ -98,14 +109,27 @@ function () {

for (i in data) {
let file = data[i];
html = html.replace(file.href, file.filename);
zip.file(file.filename, file.data, {base64: file.binary});
let folder = zip;

if (file.status == 200) {
if (file.path) {
file.path = file.path.replace(/^\//, "");
folder = zip.folder(file.path);
} else {
folder = zip;
}

let url = (file.path ? file.path + "/" : "") + file.filename.trim().replace(/^\//, "");
html = html.replace(file.href, url);

folder.file(file.filename, file.data, {base64: file.binary});
}
}

zip.file("index.html", html);
zip.generateAsync({type:"blob"})
.then(function(content) {
saveAs(content, "template.zip");
saveAs(content, Vvveb.FileManager.getCurrentPage());
});
}).catch((error) => {
console.log(error)
Expand Down
7 changes: 4 additions & 3 deletions new-page-blank-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
<meta name="author" content="">
<title>My page</title>
<!-- Bootstrap core CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.3.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<style>
html, body
{
Expand Down

0 comments on commit 44f439c

Please sign in to comment.