Browse Source

Added commit hash below copyright

master^2
TGRCDev 4 months ago
parent
commit
f848db0991
No known key found for this signature in database GPG Key ID: 3A975199085322C3
4 changed files with 52 additions and 4 deletions
  1. +2
    -1
      .gitignore
  2. +33
    -1
      __init__.py
  3. +12
    -0
      static/styles/default_dark.css
  4. +5
    -2
      templates/base_page.html

+ 2
- 1
.gitignore View File

@ -7,4 +7,5 @@ bearer-token.json
lib/wcwp_rust/target
lib/wcwp_rust/Cargo.lock
lib/whatcanweplay.pyd
lib/bin
lib/bin
.wcwp-commit-hash

+ 33
- 1
__init__.py View File

@ -75,6 +75,7 @@ def create_app():
contact_email = config["contact-email"]
privacy_email = config.get("privacy-email", contact_email)
connect_timeout = config.get("connect-timeout", 0.0)
commit_hash_filename = config.get("commit-hash-file", ".wcwp-commit-hash")
donate_url = config.get("donate-url", "")
if connect_timeout <= 0.0:
connect_timeout = None
@ -114,15 +115,46 @@ def create_app():
print("cookies set to expire after %f seconds" % cookie_max_age)
print("cache set to expire after %f seconds" % cache_max_age)
def fetch_and_store_commit_hash():
f = open(commit_hash_filename, "w")
import subprocess
try:
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
f.write(commit_hash)
f.close()
return commit_hash
except subprocess.CalledProcessError:
return ""
@app.before_first_request
def before_first_request():
fetch_and_store_commit_hash()
def get_commit_hash():
try:
f = open(commit_hash_filename, "r")
hash = f.read()
print(hash)
return hash
except Exception:
traceback.print_exc()
return ""
def basic_info_dict():
email_rev = contact_email.split("@")
return {
basic_info = {
"contact_email_user_reversed": email_rev[0][::-1],
"contact_email_domain_reversed": email_rev[1][::-1],
"source_url": source_url,
"donate_url": donate_url
}
commit = get_commit_hash()
if commit:
basic_info["commit"] = commit
return basic_info
# Tries to fetch the Steam info cookie, returns an errcode and a dict
#
# Errcodes:


+ 12
- 0
static/styles/default_dark.css View File

@ -79,9 +79,21 @@ html, body {
color:gold; /* give me money */
}
#commit {
font-size: smaller;
font-family: 'Courier New', Courier, monospace;
}
/* Desktop Overrides */
@media (min-width: 601px) {
#body-box {
max-width: 1000px;
}
}
/* Mobile Overrides */
@media (max-width: 600px) {
#commit {
display: none;
}
}

+ 5
- 2
templates/base_page.html View File

@ -60,9 +60,12 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
{% endblock %}
</div>
<div id="footer-box">
<div id="copyright">© 2020 TGRCDev</div>
<div>
<div id="copyright">© 2020 TGRCDev</div>
{% if commit %}<div id="commit">Commit <a href="{{ source_url + '/commit/' + commit }}">{{ commit }}</a></div>{% endif %}
</div>
<nav id="footer-nav">
<a id="donate" href="{{ donate_url }}">Donate</a> | <a href="/privacy">Privacy</a> | <a href="https://git.tgrc.dev/TGRCDev/WhatCanWePlay">Source</a> | <a id="contact-link">Contact</a>
<a id="donate" href="{{ donate_url }}">Donate</a> | <a href="/privacy">Privacy</a> | <a href="{{ source_url }}">Source</a> | <a id="contact-link">Contact</a>
</nav>
</div>
</div>


Loading…
Cancel
Save