forked from andyzg/gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
194 additions
and
329 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,11 @@ <h2 class="header">{{ site.full_name }}</h2> | |
<div class="footer">Made by <a class="author" | ||
href="http://andyzhang.net/">Andy Zhang</a></div> | ||
</body> | ||
<script | ||
<script | ||
src="https://code.jquery.com/jquery-3.2.1.js" | ||
integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" | ||
crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lazyload.js"></script> | ||
<script src="js/transition.js"></script> | ||
<script src="js/zoom.min.js"></script> | ||
<script src="js/gallery.js"></script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,42 @@ | ||
import os | ||
import re | ||
import shutil | ||
import sys | ||
|
||
PHOTO_PATH = './photos/' | ||
|
||
|
||
def is_image_path(path): | ||
return path.endswith('jpg') or \ | ||
path.endswith('jpeg') or \ | ||
path.endswith('png') | ||
|
||
|
||
def to_min_path(path): | ||
# Oh god this code sucks, plz fix | ||
if path.endswith('jpg'): | ||
return path.replace('.jpg', '.min.jpg') | ||
if path.endswith('jpeg'): | ||
return path.replace('.jpeg', '.min.jpeg') | ||
if path.endswith('png'): | ||
return path.replace('.png', '.min.png') | ||
|
||
for folder in os.listdir(PHOTO_PATH): | ||
# Ignore other files like .DS_Store | ||
if not os.path.isdir(PHOTO_PATH + folder): | ||
continue | ||
|
||
for f in os.listdir(PHOTO_PATH + folder): | ||
path = PHOTO_PATH + folder + '/' + f | ||
if is_image_path(path) and '.min.' not in path: | ||
min_path = to_min_path(path) | ||
shutil.copy(path, min_path) | ||
return re.search(r'\.(jpe?g|png)$', path) | ||
|
||
|
||
def get_min_path(path): | ||
return re.sub(r'\.(png|jpe?g)$', '.min.\g<1>', path) | ||
|
||
|
||
def get_placeholder_path(path): | ||
return re.sub(r'\.(png|jpe?g)$', '.placeholder.\g<1>', path) | ||
|
||
|
||
def get_path(path, ext): | ||
return re.sub(r'\.(png|jpe?g)$', '.' + ext + '.\g<1>', path) | ||
|
||
|
||
def is_original(path): | ||
return '.min.' not in path and '.placeholder.' not in path | ||
|
||
|
||
def main(ext): | ||
for folder in os.listdir(PHOTO_PATH): | ||
# Ignore other files like .DS_Store | ||
if not os.path.isdir(PHOTO_PATH + folder): | ||
continue | ||
|
||
for f in os.listdir(PHOTO_PATH + folder): | ||
path = PHOTO_PATH + folder + '/' + f | ||
if is_image_path(path) and is_original(path): | ||
min_path = get_path(path, ext) | ||
shutil.copy(path, min_path) | ||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters