Commit Graph

47 Commits

Author SHA1 Message Date
W-Mark Kubacki
72bc6932b0 browse: Jail the root directory using http.Dir() 2016-04-19 03:48:27 +02:00
W-Mark Kubacki
7f35600b28 browse: Emit datetime in UTC instead of the server's timezone
Makes sure the view is the same no matter where a site is hosted.
2016-04-19 00:56:47 +02:00
W-Mark Kubacki
239f6825f7 browse: When sorting by size, offset directories
Assigns negative sizes to directories in order to have them listed reliably
before any zero-sized files. That order is what most users expect when
sorting by size.

As side effect directories will appear before files on all filesystem
implementations. To give an example: before this change directories had a size
of 4 KiB when using Linux with ext4 or tmpfs, and with ZFS a size resembling
an estimation of the number of leaves within said directory.
2016-04-19 00:20:44 +02:00
W-Mark Kubacki
1d38d113f8 browse: Move predicate 'limit' to ServeListing
This keeps the interface of all available formatters honest,
and allows for truncated listings all formats.
2016-04-19 00:20:44 +02:00
W-Mark Kubacki
6908136092 browse: Split ServeHTTP into small specialized functions 2016-04-19 00:20:44 +02:00
W. Mark Kubacki
2f2d357fb6 browse: Fix known bugs (#770)
* browse: Catch the case of a directory disappearing before having been read

* browse: Revert to old pass-through behaviour

PROPFIND is a request for an alternate view on a directory's contents, which
response is indeed not implemented but ideally allowed to ask for.
OPTIONS would ideally return (at least) what methods the requestor could use,
which is an allowed request method, too.

This addresses #767.
2016-04-18 11:42:36 -06:00
W-Mark Kubacki
c05c5163e2 browse: Don't leak Cookies to sessions in HTTP from HTTPS 2016-04-17 01:16:17 +02:00
W-Mark Kubacki
4a6121f989 Tell usage of 'path' from 'filepath' and fix *path checking 2016-04-17 01:16:16 +02:00
W-Mark Kubacki
4e98cc3005 browse: Return HTTP errors on unhandled HTTP methods
For example, a HTTP POST should not be answered with StatusOK,
and a response to HTTP OPTIONS should not carry any contents.
2016-04-15 18:22:51 +02:00
Thomas Boerger
ef95173827
Dropped LinkedPath and updated browse template
As discussed with @mholt I have dropped the old LinkedPath function and
replaced it within the browse template with the new BreadcrumbMap
function. Visually it looks exactly the same as before, now the template
functionality is just more powerful.

Signed-off-by: Thomas Boerger <tboerger@suse.de>
2016-04-12 17:18:21 +02:00
Thomas Boerger
e0b63d92f4
Added breadcrumb map function to browse
In order to being able to really build a custom template for the browse
directive I have added another function to build even custom breadcrumb
paths. The other function `LinkedPath` is not that easy styleable as
this map function. That way we are able to build the breadcrumb path
matching different CSS frameworks like Bootstrap.

Signed-off-by: Thomas Boerger <thomas@webhippie.de>
2016-04-11 21:47:44 +02:00
buddhamagnet
c981b08b23 correct unused assignments 2016-03-26 21:05:19 +00:00
Matthew Holt
e74558eaea browse: Fix for files and dirs with ':' in name 2016-01-13 13:17:58 -07:00
Matthew Holt
060ab92d29 Reorder a few things
The docs link to this structure and all its methods related to the browse template; keeping them together makes it possible to link to the whole block of code that is relevant.
2016-01-10 09:47:26 -07:00
Matthew Holt
94e3e7e5eb browse: New default template 2015-12-31 00:23:10 -07:00
buddhamagnet
57f1d3c205 pass golint
pass all tests

respond to maintainer comments

reinstate assignment of t

correct typo

correct typo

pass linter some more
2015-11-05 00:40:35 +00:00
Zac Bergquist
f9bc74626d Address various lint and gocyclo warnings. Fixes #253 2015-10-11 16:28:02 -04:00
Matthew Holt
d414ef0d0f browse: Fix tests that fail only in CI environment
... I think. Submitting as PR to double-check. This change changes file mod times on the testdata to ensure they are not all the same so that the sort is predictable!
2015-10-10 19:53:11 -06:00
Karthic Rao
f5cd4f17f8 Exhaustive test coverage to test the usage of sort,order and limit parameter for the browse middleware 2015-10-09 11:28:11 +05:30
Matthew Holt
10ab037833 Moved fileServer and browse.IndexPages into middleware package 2015-09-19 20:35:48 -06:00
Henrique Dias
8120e57850 add user defined variables into browse template 2015-09-18 08:52:12 +01:00
Henrique Dias
30b19190dc add ignoreIndexes option to browse 2015-09-17 20:33:39 +01:00
Karthic Rao
ed4148f20e Complete test coverage for replacer for Go 2015-09-10 10:28:13 +05:30
karthic rao
e3cea042d6 Left over comments removed
Redundant comments in the code removed
2015-08-30 19:00:35 +05:30
Karthic Rao
679668e3c0 removed redundant comment lines 2015-08-30 18:57:20 +05:30
Karthic Rao
730269743f Json response initial test for browse.go 2015-08-29 08:04:01 +05:30
pyed
b9d3e7721e Fixing my comment
the old comment might throw the source-reader off, my bad.
2015-08-27 18:01:46 +03:00
Abdulelah Alfuntukh
414b47d653 adds json option for the browse middleware 2015-08-24 23:37:11 +03:00
Matthew Holt
35e25be1a4 browse: Size displayed in IEC format
Powers of 2, or base 1024, rather than powers of 10 or base 1000. The powers of 2 are technically more accurate.
2015-07-29 19:15:38 -06:00
Matt Holt
bf47951f3a Merge pull request #196 from evermax/master
markdown, browse: Integrated Context struct for templating
2015-07-25 15:15:51 -06:00
Matthew Holt
a578c43810 browse: Add txt files to list of default files 2015-07-24 10:27:19 -06:00
pyed
1589129ea1 Save sorting preferences as cookies
To be used across directories
2015-07-23 13:25:03 +03:00
Maxime
bc2feece4b Moved test files to testdata folder.
Changed the tests accordingly.
2015-07-23 09:35:46 +02:00
Maxime
2d5320c454 Added test for the browse directive
Created sample files for the test
2015-07-18 11:37:05 +02:00
Maxime
f536bc94b2 Added the Context to the browse directive
Moved the Context type to middleware and exported it.
Users can use .Include and others in browse directive templating
Created test for the templates directive.
2015-07-17 20:07:24 +02:00
pyed
68add78230 Implement sorting functionality for "Browse" 2015-06-21 18:04:47 +03:00
Zac Bergquist
e4b50aa814 Fix more lint warnings 2015-05-24 22:52:34 -04:00
Abiola Ibrahim
a1312465b5 browse: return forbidden (403) only when it is a permission error. 2015-05-10 17:58:44 +01:00
Matthew Holt
e4fdf171c7 More refactoring - nearly complete 2015-05-04 11:49:49 -06:00
Matthew Holt
1a8f753303 Meh. 2015-04-21 21:41:58 -06:00
Matthew Holt
23f7f5ebba Minor UI tweaks to directory listings 2015-04-21 21:36:43 -06:00
Matthew Holt
bdd145b0de Better error handling when executing templates 2015-04-21 21:36:30 -06:00
Matthew Holt
d33256f1dc Refactor: Middleware chain uses Handler instead of HandlerFunc 2015-04-02 23:30:54 -06:00
Matthew Holt
843f6e83a9 Refactored browse middleware to return errors 2015-03-28 16:46:54 -06:00
Matthew Holt
63b39c78ee Better default template; other fixes 2015-03-24 23:05:42 -06:00
Matthew Holt
9672850d11 Bug fixes and improvements for browse middleware 2015-03-24 21:54:33 -06:00
Matthew Holt
00e43197fd Started browse middleware to list directory contents 2015-03-24 20:12:48 -06:00