Browse Source

Minor cosmetic updates and fix list template due to Command update from commit @0f8b1cbd3b (#52)

1. Commit: @0f8b1cbd3b changed `Commands` to `Command` in `server.go`, specifically Line 223.  This broke the `list.html` range template.  Small change to fix that.
    > Line 223 (server.go): `ctx.Set("Command", cmd)`

2. The dockerfile itself, just swapped `github.com` references to `git.mills.io` in order for it to actually build on my system.. and it's no longer on Github ;).

3. Added a simple update to the `base.html` to add a link directly to `list`, for the lazy who like to click vice type it in. Small QoL update.
![image](/attachments/25096cda-2677-4a7c-a022-6d475c6f3cdf)

4. Added a button for each bookmark to have a red **X** to do a simple remove from the `list.html` page instead of looking at what you want to remove and then address bar typing it or going back. Small QoL fix.
![image](/attachments/13379baa-c314-43cf-8858-8628ab1c2f0c)

5. I've changed the docker `start.sh` script to actually use **environment** variables.  This will enable the environment syntax (instead of using **command**) in compose files such as:
    ### New
    ```yaml
    environment:
      - BIND=0.0.0.0:8000
      - BASEURL=http://golinks.mydomain.net
      # BASEURL is extremely convenient when proxying it
    ```
    ### Old
    ```yaml
    command:
      - bind=0.0.0.0:8000
      - fqdn=http://golinks.mydomain.net
    ```
    This also prevents from passing something unexpected to golinks.

6. Lastly!  Can you push an updated docker image to Docker Hub?  The one on DockerHub is  golinks 0.0.5 and the version (before this pull request) is 0.0.7.

Co-authored-by: brokenscripts <brokenscripts@protonmail.com>
Reviewed-on: #52
Co-authored-by: brokenscripts <brokenscripts@noreply@mills.io>
Co-committed-by: brokenscripts <brokenscripts@noreply@mills.io>
master
brokenscripts 1 week ago committed by James Mills
parent
commit
9f7b49eeb9
  1. 26
      .dockerfiles/start.sh
  2. 6
      Dockerfile
  3. 3
      templates/base.html
  4. 6
      templates/list.html

26
.dockerfiles/start.sh

@ -1,5 +1,25 @@
#!/bin/sh
BIND="${BIND:-0.0.0.0:8000}"
BASEURL="${BASEURL:-http://localhost:8000}"
DBPATH="${DBPATH:-/search.db}"
TITLE="${TITLE:-Search}"
SEARCHURL="${SEARCHURL:-https://www.google.com/search?q=%s&btnK}"
SUGGESTURL="${SUGGESTURL:-https://suggestqueries.google.com/complete/search?client=firefox&q=%s}"
CONFIG="${CONFIG-}"
PORT="${PORT:-8000}"
exec golinks -bind=0.0.0.0:"$PORT" "$@"
if [ ! -z "$CONFIG" ]
then
echo "Executing golinks with a provided config file:"
echo " -config=$CONFIG"
exec golinks -config "$CONFIG"
else
echo "Executing golinks with the following parameters:"
echo " -bind=$BIND"
echo " -baseURL=$BASEURL"
echo " -dbpath=$DBPATH"
echo " -title=$TITLE"
echo " -searchURL=$SEARCHURL"
echo " -suggestURL=$SUGGESTURL"
exec golinks -bind="$BIND" -baseURL="$BASEURL" -dbpath="$DBPATH" -title="$TITLE" -searchURL="$SEARCHURL" -suggestURL
="$SUGGESTURL"
fi

6
Dockerfile

@ -10,8 +10,8 @@ ENV REPO prologic/$APP
RUN apk add --update git make build-base && \
rm -rf /var/cache/apk/*
WORKDIR /go/src/github.com/$REPO
COPY . /go/src/github.com/$REPO
WORKDIR /go/src/git.mills.io/$REPO
COPY . /go/src/git.mills.io/$REPO
RUN make TAG=$TAG BUILD=$BUILD build
# Runtime
@ -24,7 +24,7 @@ LABEL golinks.app main
COPY .dockerfiles/start.sh /start.sh
COPY --from=build /go/src/github.com/${REPO}/${APP} /usr/local/bin/${APP}
COPY --from=build /go/src/git.mills.io/${REPO}/${APP} /usr/local/bin/${APP}
EXPOSE 8000/tcp

3
templates/base.html

@ -14,8 +14,9 @@
<section class="container grid-960 mt-10">
<header class="navbar">
<section class="navbar-section">
<a href="{{ .BaseURL }}/" class="navbar-brand mr-10">Golinks</a>
<a href="{{ .BaseURL }}/" class="navbar-brand mr-2">Golinks</a>
<a href="{{ .BaseURL }}/help" class="btn btn-link">Help</a>
<a href="{{ .BaseURL }}/list" class="btn btn-link">List</a>
</section>
<section class="navbar-section"></section>
</header>

6
templates/list.html

@ -7,13 +7,15 @@
<thead>
<tr>
<th>Name</th>
<th class="text-center">Remove</th>
<th class="text-left">URL</th>
</tr>
</thead>
<tbody>
{{ range .Bookmarks }}
<tr>
<th><code>{{ .Name }}</code></th>
<td><code>{{ .Name }}</code></td>
<td class="text-center"><a href="{{ $.BaseURL }}/?q=remove+{{ .Name }}"> <button class="btn btn-error btn-sm"> <i class="icon icon-cross"></i></button></a></td>
<td>{{ .URL }}</td>
</tr>
{{ end }}
@ -29,7 +31,7 @@
</tr>
</thead>
<tbody>
{{ range .Commands }}
{{ range .Command }}
<tr>
<th style="vertical-align: baseline;"><pre><code>{{ .Name }}</code></pre></th>
<td><pre>{{ .Desc }}</pre></td>

Loading…
Cancel
Save