Skip to content

Commit 071f03c

Browse files
Merge branch 'main' into main
2 parents 0e4e7d8 + fb415b8 commit 071f03c

File tree

4 files changed

+85
-37
lines changed

4 files changed

+85
-37
lines changed

.github/workflows/ci.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI Pipeline
2+
3+
on:
4+
release:
5+
branches: ["main"]
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3
13+
- name: Login Dockerhub
14+
env:
15+
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
16+
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
17+
run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
18+
19+
- name: Build the Docker image
20+
run: docker build -t mrsunglasses/linkliberate .
21+
- name: Push to Dockerhub
22+
run: docker push mrsunglasses/linkliberate:latest

src/link_liberate/templates/base.html

+46-31
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
}
2424

2525
a {
26-
text-decoration: none !important;
26+
text-decoration: none !important;
2727
}
2828

2929
h1 {
@@ -59,44 +59,59 @@
5959
}
6060

6161
.tooltip {
62-
position: relative;
63-
display: inline-block;
64-
border-bottom: 1px dotted black;
62+
position: relative;
63+
display: inline-block;
64+
border-bottom: 1px dotted black;
6565
}
6666

6767
.tooltip .tooltiptext {
68-
visibility: hidden;
69-
width: 120px;
70-
background-color: #555;
71-
color: #fff;
72-
text-align: center;
73-
padding: 5px 0;
74-
border-radius: 6px;
75-
76-
position: absolute;
77-
z-index: 1;
78-
bottom: 125%;
79-
left: 50%;
80-
margin-left: -60px;
81-
82-
opacity: 0;
83-
transition: opacity 0.3s;
68+
visibility: hidden;
69+
width: 120px;
70+
background-color: #555;
71+
color: #fff;
72+
text-align: center;
73+
padding: 5px 0;
74+
border-radius: 6px;
75+
76+
position: absolute;
77+
z-index: 1;
78+
bottom: 125%;
79+
left: 50%;
80+
margin-left: -60px;
81+
82+
opacity: 0;
83+
transition: opacity 0.3s;
8484
}
8585

8686
.tooltip .tooltiptext::after {
87-
content: "";
88-
position: absolute;
89-
top: 100%;
90-
left: 50%;
91-
margin-left: -5px;
92-
border-width: 5px;
93-
border-style: solid;
94-
border-color: #555 transparent transparent transparent;
87+
content: "";
88+
position: absolute;
89+
top: 100%;
90+
left: 50%;
91+
margin-left: -5px;
92+
border-width: 5px;
93+
border-style: solid;
94+
border-color: #555 transparent transparent transparent;
9595
}
9696

9797
.tooltip:hover .tooltiptext {
98-
visibility: visible;
99-
opacity: 1;
98+
visibility: visible;
99+
opacity: 1;
100+
}
101+
102+
.copy-button {
103+
background-color: #4CAF50;
104+
color: #fff;
105+
padding: 12px 20px;
106+
border: none;
107+
border-radius: 4px;
108+
cursor: pointer;
109+
font-size: 16px;
110+
margin-left: 10px;
111+
}
112+
113+
.copy-button:hover {
114+
background-color: #45a049;
100115
}
101116
</style>
102117
<title>
@@ -112,4 +127,4 @@
112127
{% endblock %}
113128
</body>
114129

115-
</html>
130+
</html>

src/link_liberate/templates/showlibrate.html

+16-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,22 @@
1919
<a href="/"><h1>🔗LinkLiberate🪽</h1></a>
2020
<div class="form-container">
2121
<p>Link: </p><a href="{{ link }}">{{ link }}</a>
22-
<p>Short: </p><a href="{{ short }}">{{ short }}</a>
22+
<p>Short: </p><a id="shortLink" href="{{ short }}">{{ short }}</a>
23+
<button class="copy-button" onclick="copyTextToClipboard('shortLink')">Copy</button>
24+
2325
</div>
2426
</div>
27+
<script>
28+
// Javascript to simply copy text in elementID to user's clipboard
29+
function copyTextToClipboard(elementId) {
30+
var text = document.getElementById(elementId).textContent || document.getElementById(elementId).innerText;
31+
navigator.clipboard.writeText(text).then(function() {
32+
console.log("Text copied to clipboard");
33+
})
34+
.catch(function(err) {
35+
console.error('Error in copying text: ', err);
36+
});
37+
}
38+
</script>
39+
2540
{% endblock %}

src/link_liberate/utils.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ def generate_uuid() -> str:
1414

1515
return random_code
1616

17-
1817
def make_proper_url(url: str) -> str:
19-
if url.startswith("http://") or url.startswith("https://"):
20-
return url
21-
else:
22-
return f"https://{url}"
18+
return f"https://{url}" if not url.startswith(("http://", "https://")) else url
2319

2420

2521
def check_link(link: str) -> bool:

0 commit comments

Comments
 (0)