Commit graph

57 commits

Author SHA1 Message Date
Gabriel Simmer 53ffe69bdc Trigger CI/CD. 2021-05-23 15:40:20 +01:00
Gabriel Simmer b90abd8779 Remove old file path function. 2021-05-23 14:46:28 +01:00
Gabriel Simmer 54fe5f9c5c Simplify file serving from local or remote.
Prior, we would decide how to serve a file based on whether it was local
or remote at a router level. This moves everything to an io.Copy call in
the router with the Provider returning an io.Reader.
2021-05-23 14:43:27 +01:00
Gabriel Simmer 8127aaa6a8
Merge pull request #5 from gmemstr/refactoring
Huge refactoring, simplification and expansion.
2020-04-24 09:25:51 +01:00
Gabriel Simmer 396c5914f6
Renaming application from "NAS" to "Sliproad". 2020-04-24 09:22:33 +01:00
Gabriel Simmer ab6bcad510
Add blurb about authentication to README. 2020-04-24 09:13:06 +01:00
Gabriel Simmer ce4ee64509
Minor linting fixes & move to CircleCI/UPX orb.
Some minor linting fixes and general style/scope changes, which should
have no impact on the overall application. Also moved to the offical
CircleCI UPX Orb, rather than my own (which is still maintained by me).
2020-04-24 09:01:53 +01:00
Gabriel Simmer c559f28ebb
Authentication handling with Keycloak.
Implemented a rudementary authentication method using Keycloak as the
IdP - still very barebones, but login does function. Next steps will
include a Docker Compose file (most likely) for managing this
integration. The application will work fine without setting up the
integration however, and will just throw a warning message. Setup should
be relatively self explanatory, but some documentation is TBD, along
with some automation when spinning up for the first time. Still not
super happy with the implementation.
2020-04-16 23:49:35 +01:00
Gabriel Simmer 5e85a600d8
Simplify file router, add documenting comments.
The file router was starting to get out of hand, so I've done my best to
simplify it and get ahead of more spaghetti. As part of this, tidied up
some other code and added some much-needed comments and constants to
make things more readable. ObjectInfo() is much more useful as well,
determing if a file exists, if it's a directory and the location.

Feeling other bits of the project can be simplified, but mostly been
focused on the file providers and associated router.
2020-04-15 23:19:33 +01:00
Gabriel Simmer 8db4a35994
Better handling of serving files, frontend tweaks.
Implemented a few new functions to handle the differences between local
and remote files - local files will be served (best it can be) with
ServeContent(), while remote files will be passed through from the
response body directly to the response writer. This isn't a very elegant
solution right now, but hoping to refactor this approach and simplify
the decision logic. However, serving files from local disks is much
better, including improvements to video files and generally better
handling of metadata.

Also some small tweaks to the frontned to align things a little nicer.
2020-04-15 12:16:27 +01:00
Gabriel Simmer e1b8c50d55
Delete files and create directories.
Added DELETE handler to files endpoint for deleting files and
directories, along with new handling for creating directories, as
specified with the `X-NAS-Type` header - if this is set to "directory",
a new directory is created with the path of the request. Otherwise, an
attempt to parse the file from form data is done as before.

Also added buttons to interact with the new functionality in the default
frontend.
2020-04-12 22:10:51 +01:00
Gabriel Simmer 1ba1a14807
New file regex.
The old regex was hard to parse and maintain, and was broken for some
edge cases. Simplified it greatly and seems to work fine!
2020-04-11 22:43:03 +01:00
Gabriel Simmer a686cb8c53
Added 'SHELL' enviornment variable to Makefile.
This is a workaround for the CircleCI Docker image, and should be
removed soon-ish. Before patching, the `make_build_dir` Makefile command
would fail, producing a single directory rather than all 3.
2020-04-07 10:26:19 +01:00
Gabriel Simmer 10779b8000
Preparing for 2.0, improved dist command.
Packing binaries and files in a more sane manner, which should make
distributing releases easier moving forward. Will likely replace the
NAS_VERSION variable with something more dynamic moving forward.
2020-04-06 23:56:57 +01:00
Gabriel Simmer cdf8c9a598
Implement new UPX Orb for CircleCI. 2020-04-06 22:51:56 +01:00
Gabriel Simmer 5e345f11af
Tweaked spacing for file list, icons.
Icons! Finally, signifying type of link without relying on colours. Also
added some margin to help alleviate strain from contrasting colours.
Fixed background-color of "NAS" home link maintaining white background.
2020-04-05 19:32:35 +01:00
Gabriel Simmer 2a17dbc178
Restyled frontend with nicer colours and layout.
Got some good pointers for how to layout directories, so took the chance
to add a nicer colour palette. May tweak this a little later down the
line, but blue = directory, red = file.
2020-04-03 21:19:59 +01:00
Gabriel Simmer 59c79fc4fe
Support for special characters in filename.
Previously, spaces or other special characters in filenames were borked
because of how the filenames were passed through to the ViewFile
function - with escaped strings (%020 instead of " "). Added a
QueryUnescape call, and slightly tweaked the router to use a filename
rather than accessing var everytime.
2020-04-03 21:17:43 +01:00
Gabriel Simmer 0902f8a429
Tweaking cache for CI 2020-04-03 13:57:54 +01:00
Gabriel Simmer 2ab4de5526
Improve UPX install for CI 2020-04-03 13:47:16 +01:00
Gabriel Simmer a5494c8811
Fine-tuning UPX and CircleCI configuration. 2020-04-03 13:38:21 +01:00
Gabriel Simmer 750b85c261
Triggering CircleCI build. 2020-04-03 13:29:59 +01:00
Gabriel Simmer c28851fcc3
Tests & CI, io.Reader > Multipart file.
Making some improvements to the future maintainability of the project,
namely in the form of tests. Also implemented a new "dist" command to
the Makefile that packs up the binaries, and will eventually be expanded
to do more legwork when prepping for a release.

Updated file providers to use io.Reader over an explicit multipart file,
and removed the handler in favour of a plain filename, since that was
it's primary purpose.
2020-04-03 13:26:06 +01:00
Gabriel Simmer c183003953
Resolve upload logic for frontend.
Frontend logic for routing was a bit broken when generating links for
directories, appending an extra / to the start. Resolved this to
properly link - interestingly, the file listing could still be served,
but the uploading was broken?

Also enforced regex for provider of directory listings and tidied up
some other string handling.
2020-04-03 02:51:38 +01:00
Gabriel Simmer 641e015ca6
Simplify router, remove common and authentication.
Removed common package, since it was largely useless and instead
integrated what I could into the router package. Should simplify things
going forward, but we can always split this out later. Also completely
removed authentication for the time being - want to consider other
options for this.
2020-04-02 20:50:39 +01:00
Gabriel Simmer 207676d4a7
Correct config provider, no backblaze goroutine.
Addressing a bug where the configuration would try to interpret the
provider name from the entry in the configuration, rather than the
explicit `provider`. Also removed background uploading from Backblaze
(was worth a shot).
2020-04-02 15:31:30 +01:00
Gabriel Simmer 58128a0e98
File upload progress and Makefile commands.
Implemented file upload progress to the frontend using XMLHttpRequests,
since fetch() doesn't offer this functionality right now. Bit of a
fragmented approach to requests in the codebase right now, but hope to
resolve this soon. Not styled at all either.

Also added some nifty commands to the Makefile for producing smaller
binaries using some compiler flags and upx, and requires upx to be
installed (make small and make small_pi).
2020-03-31 01:16:12 +01:00
Gabriel Simmer a765d52e4b
Update README, add configuration examples.
Expanded the README with more up-to-date data and elaboration on
providers, which may have been a bit unclear before. Also added a few
configuration examples for each provider, with comments.
2020-03-31 00:03:50 +01:00
Gabriel Simmer d86ed1233f
Implemented uploading for Backblaze & Disk (v1)
Implemented file uploading for both the disk and Backblaze providers.
Also implements a UI element and frontend logic for doing so from the
frontend.

Disk will write directly to disk, while the Backblaze provider will
attempt to stream the file from memory directly to the POST body. This
could introduce some problems down the line, so caching to disk then
uploading in the background may need to be implemented. It also
performs the final upload using a goroutine so the end client can
continue on it's merry way.

Backblaze proved a bit tricky to do, and considering switching to using
a library for managing Backblaze going forward.
2020-03-30 20:51:26 +01:00
Gabriel Simmer 9cd7ab75e8
Better error messages for Backblaze, int64.
Ran into an issue when running on a Raspberry Pi - occaisonally, the
int size for the files being provided from Backblaze (which is in
bytes) will be too large. This is fixed by upgrading the int to int64.
As a part of this debugging process, I upgraded the error handling when
fetching the Backblaze file listing to actually print the errors rather
than failing silently.
2020-03-23 10:53:58 +00:00
Gabriel Simmer f54ad74ec7
Responsive media queries for grid.
Currently just reverts to displaying as a block with some margin, but
it does scale really well. Useful for mobile devices.
2020-03-22 21:26:00 +00:00
Gabriel Simmer bb03aa9b8f
Subdirectory handling in frontend, README
Updated READMe a bit for providers, allowed frontend to better handle
linking to subdirectories (previously didn't work at all!).
2020-03-22 21:15:31 +00:00
Gabriel Simmer 292e24978d
Implement new frontend, "/" at end of provider.
Started work on a new basic frontend, with some magic code from
@tomhodgins (Tom Hodgins) for templating and processing data, which was
the primary purpose for considering a full-fledged JavaScript
framework. Fairly simple right now, with minimal "bling", and seems
"functional enough". Might need to consider options for using less or
no JS down the line if there is demand.

As part of this frontend, actually implemented route logic for fetching
a sorted list of providers (might be worth investigating whether
storing this final result in memory is worth the performance to memory
trade-off).

Also fixed a bug where adding "/" to the end of a provider name without
a file path would result in a 404. This was addressed with some Regex
filtering on the path that should be able to handle that matching.
2020-03-22 00:18:19 +00:00
Gabriel Simmer 49dba732d3
Implement Setup() function for providers, cleanup
Implemented a much-needed Setup() function for providers to implement,
which (as demonstrated in the backblaze provider) allows for
authentication in advance of needing to make calls to remote locations.
This could also be used to create a directory or perform some other
sanity check required for the provider to work. So far, haven't noticed
any performance impacts from this approach, besides not needing to auth
each time we make a request.
2020-03-21 00:31:24 +00:00
Gabriel Simmer 7450d229f4
Remove React frontend
Considering other options for a web frontend for this project, including
vue or vanilla javascript.
2020-03-19 10:15:46 +00:00
Gabriel Simmer c2171d00c9
io.Copy rather than ioutil.ReadAll
Should offer some speed boost, copying the file contents rather than
reading it all to memory then writing it back out. Should theoretically
be able to handle larger files as well, although some benchmarks
are TBD around filesize limits.
2020-03-19 10:13:38 +00:00
Gabriel Simmer ea1075cb5b
Rewrite file provider to proxy data download (rather than redirect)
Reworked the fileprovider to proxy data directly from the provider
rather than attempt to funkily redirect when needed, since it was overly
complex and wouldn't work well in the long run. Temporarily added "file"
as constant return for determining the filetype through Backblaze.

Added a Makefile to make life easier as well, and rewrote the README to
reflect the refactor/rewrite and new approach to providers.
2020-03-15 23:49:00 +00:00
Gabriel Simmer bf1f06b79c Refactoring file storage to enable different providers
Expanding this as we go, currently have POC Backblaze B2 support and
basic 'disk' provider as well. Still WIP, but functional for the most
part. Also moving to simplified YAML configuration.

Overall, simplifying things to be extensible down the line. Still work
to be done, but coming along nicely.
2020-02-24 18:07:47 +00:00
Gabriel Simmer 9a2e6814f9 Add cold storage interface, go module 2020-02-22 22:43:57 +00:00
Gabriel Simmer 6524726357 Directory listing in new frontend 2019-07-27 21:43:05 -07:00
Gabriel Simmer 9ab5f248a9 Rewriting frontend in react, refactoring of routes. 2019-07-13 20:19:28 -07:00
Gabriel Simmer 88e0d6c7b1
Add disk usage statistics to index & API.
Update README.md

Add disk usage statistics to index & API.
2019-04-01 22:45:33 -07:00
Gabriel Simmer a2a1e0e573
Begin work on API, decouple frontend to be more dynamic. 2019-03-02 17:41:13 -08:00
Gabriel Simmer b07c20d43a
Fix incorrect variable name in upload function. 2019-02-28 22:40:10 -08:00
Gabriel Simmer a3d421ed3d
Actually add js file for file drag and drop. 2019-02-28 22:38:04 -08:00
Gabriel Simmer c252f1bf77
Drag and drop fileuploading (janky). 2019-02-28 22:27:13 -08:00
Gabriel Simmer 8b49d75077
Fix bug where file upload location was not respected. 2019-02-24 14:53:55 -08:00
Gabriel Simmer bd6b7c86b2
Add example config, adding instructions to README. 2019-02-24 14:51:40 -08:00
Gabriel Simmer 23177b6b54
Implement basic file uploading ('hot' tier only) 2019-02-24 14:42:21 -08:00
Gabriel Simmer 68f313c879
More regex path improvements. 2019-02-24 11:51:36 -08:00