Merge pull request #137 from ONLYOFFICE/feature/ads-banner

feature/ads-banner
This commit is contained in:
Alexey Safronov 2024-02-29 18:25:52 +04:00 committed by GitHub
commit 8fdf63f7b2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 48 additions and 0 deletions

42
campaigns.downloader.py Normal file
View File

@ -0,0 +1,42 @@
import os
from github import Github
import requests
import shutil
rd = os.path.dirname(os.path.abspath(__file__))
dir = os.path.abspath(os.path.join(rd, ".."))
publicDir = os.path.join(dir, "client/public")
g = Github()
repo = g.get_repo("ONLYOFFICE/ASC.Web.Campaigns")
repoFolder = "src/campaigns"
def download(c, out):
r = requests.get(c.download_url)
output_path = f'{out}/{c.path}'
os.makedirs(os.path.dirname(output_path), exist_ok=True)
with open(output_path, 'wb') as f:
f.write(r.content)
def download_folder(repo, folder, out, recursive):
contents = repo.get_contents(folder)
for c in contents:
if c.download_url is None:
if recursive:
download_folder(repo, c.path, out, recursive)
continue
download(c, out)
def move_folder():
srcPath = publicDir + "/src"
campaignsPath = srcPath + "/campaigns"
newPath = publicDir + "/campaigns"
if os.path.exists(newPath):
shutil.rmtree(newPath)
shutil.move(campaignsPath, newPath)
shutil.rmtree(srcPath)
download_folder(repo, repoFolder, publicDir, True)
move_folder()
print("It's OK")

View File

@ -195,6 +195,11 @@ server {
location ~* /static/images/(.*)$ {
try_files /images/$1 /index.html =404;
}
location ~* /static/campaigns/(.*)$ {
try_files /campaigns/$1 /index.html =404;
}
}
location /doceditor {

View File

@ -1,3 +1,4 @@
gitdb==4.0.11
GitPython==3.1.40
smmap==5.0.1
PyGithub==2.2.0