less: remove borders and padding around navbar items
Navbar items were styled with borders to look like embossed areas that could be clicked. The top menu also had it in the drop-down menu, while the context menu didn't.
The areas are big, and it is quite clear it is some kind of clickable menu ... and the clickable area is also highlighted when hovering. We can thus do without the borders and get a slightly cleaner look.
- 'position: absolute' and 'margin: 3px 4px;' make it actually look worse - 'text-decoration: none' is already set on all <a> - we only use it in one place so the selector can be simplified
- less spacing still leave room to show the comment bubble with hiding the line number - looks good w/o letter-spacing - bootstrap already sets box-sizing: border-box; - it is a <a> no need for cursor: pointer - width: 100% makes no difference
35d3a85fc650 introduced the Bootstrap default overflow:auto styling of pre. That made overflow hidden instead of visible, and thus broke our display of +/- as a :before with relative positioning outside the pre.
To undo that, add overflow to the list of Bootstrap pre styling we override.
When you have a big user base, with thousends of users, always using the whole dataset makes the UI slow.
This will replace kallithea/model/repo.py get_users_js and get_user_groups_js which were used to inline the full list of users and groups in the document. Instead, it will expose a json service for doing the completion.
When using the autocomplete, there might be multiple ajax requests, but tests with a userbase > 9000 showed no problems. And keep in mind, that although we now make multiple requests (one for every character) that - the autocomplete is not used that often - the requests are quite cheap - most importanly, we no longer need to calculate the user list/group list if the user doesn't use the autocomplete
Users and groups are still passed as parameters to the javascript functions - they will be removed later.
gravatar: use icon-gravatar for default gravatar sizing and styling instead of icon-empty
We may want to use a different style for gravatar then for icon-empty, so we should give it its own class, but still consider it an icon, like the default icon-user is.
style: use npm less to generate kallithea stylesheet style.css from style.less
This is a minimal change to introduce less as framework to generate our stylesheet. The input less file is currently the same as the original css stylesheet, so that the delta between the input style.less and the output style.css is zero.
To regenerate style.css from style.less, run:
npm --prefix kallithea/public/less install npm --prefix kallithea/public/less run less
style: change indentation of stylesheet to match future less output
Align the indentation of the stylesheet with the indentation that a less-compiled version of this stylesheet would use. This will allow easy comparison of the original and less-generated stylesheet in future commits.
style: remove empty lines in stylesheet to match future less output
Align the formatting of the stylesheet with the formatting that a less-compiled version of this stylesheet would use. This will allow easy comparison of the original and less-generated stylesheet in future commits.
This will also align the formatting of the stylesheet with the indentation that a less-compiled version of this stylesheet would use. This will allow easier comparison of the original and less-generated stylesheet in future commits.
diff: fix crash when displaying diff on a single file
File diff on an image file would fail on %if op in 'DM': because op was None: TypeError: 'in <string>' requires string as left operand, not NoneType
But really, if op is None, we also don't want to show invalid "Show images" links. Thus, guard the whole image display section with having an actual op.
_parse_gitdiff will never return op None, but wrapped_diff is more lazy and might do that. It could be considered a bug in wrapped_diff, and this change is just a bad workaround.
vcs: add support for Mercurial annotate in Mercurial 4.4
Mercurial fctx.annotate() returns tuples with two elements: info about the annotate line and the actual line. The code is changed to clarify that.
After Mercurial 4.4 with https://www.mercurial-scm.org/repo/hg/rev/2e32c6a31cc7 , the info is no longer a tuple but an attr object. Assume fctx is available as an attribute, but catch exceptions and fall back to indexing as before.
That can't easily be done in hgcompat, so we do it inline.
changelog: bring the right-aligned tags in a least to most common order
The goal is, to more often, have equal tags being display like a column, without giving each tag its own table cell, which would waste a lot of space. So move tags and branch, which come in singles move in front of phase, unstable, etc. which most of the time come in groups.
files: use same parent/child navigation as on changeset page
There are different reasons to do this. First, be consistent. Second, steping through the revisions by revision number is problematic. It means jumping between branches (I think even with the 'Follow current branch' checkbox this is not obvious to all the users). Also if we'd continue to use it, it'd require some special handling of hidden revisions.
files: simplify header, making it more like changeset
"Search file list" is moved out of the header to a separate div.
The "Follow current branch" functionality is dropped, and there is thus less need for passing the current URL around ... but it is generally still used for browser history navigation.
The removal of branch following is a temporary feature regression - that will be fixed next.
Binary diffs can make the diffs VERY big and cause MemoryError exceptions.
Before giving MemoryError, the system might start swapping, any process might fail when allocating memory, random processes might get killed, and our process might fail in other places. The proper fix would be to avoid the problem by not trying to process more data than we can handle - for example by not processing more than a certain amount of Git output.
Before, memory errors were shown to the user as a 500 Internal Server Error page.
Now, as long as we have no better/safer way get the diff, catch the MemoryError and show the page with a flash error message and no diff.
The error handling is placed in the diffs module to avoid leaking flash messages into the vcs lib.
config: tweak template http_server conditionals - don't leave an empty section when using UWSGI
The web servers run by 'gearbox serve' share the same basic configuration:
[server:main] host = ... port = ... use = egg:... ...
UWSGI doesn't use gearbox and doesn't use a [server:main] section but will read it's own section:
[uwsgi] http = ...:... ...
Before, 'make-config my.ini http_server=uwsgi' would create an empty [server:main] section, and only after 6a5fb5070765 it stopped putting unused host/port information there.
Now, let everything but UWSGI share the [server:main] template section and put host/port first. Everything UWSGI is handled in its own conditional template section.
- use jQuery instead of YUI in js code - since the old library used seconds and the new library uses ms we have to make timestamps 1000 times bigger - the new library uses a slightly different data format
auth: consume request body before responding 401 or 403 during authentication
In order to work correctly with reverse proxies like Apache, the application needs to consume the whole body before returning and closing the connection. Otherwise the reverse proxy may complain about a broken pipe.
For example, if the client sends a lot of data and kallithea doesn't read all that data before sending 401, the connection will be closed before the reverse proxy has sent all the data. In this case an apache reverse proxy will fail with a broken pipe error.
This is not necessary for all wsgi servers. Waitress automatically buffers (and therefore reads) all the data and uwsgi has a 'post-buffering' option to do the same. But AFAIK there is no way to push to a password protected hg repository when using gunicorn without this changeset.
commands: remove custom (re-)initializing of database model
The model has already beeen initialized through TurboGears after make_app_without_logging has been called.
Since kallithea.lib.utils2.engine_from_config no longer is used, remove it. All remaining references to engine_from_config are directly to the one from sqlalchemy.
diffs: move as_html and _safe_id from method to a pure function - avoid calling the method as function
as_html was sometimes used in a way where we actually don't want to use the whole DiffProcessor - we just created a dummy instance and passed custom input as parameter to the instance method.
Instead, make it the function we apparently want.
Make it clear that as_html not just returns a "diff" but that it is a html diff.
diffs: do check of cut_off_limit on the raw diff before any parsing and allocation
This redefines the exact meaning of cut_off_limit but it will still be approximately the same thing. It makes it more a limitation of what amount of work should be done, more than how much html should be outputted.
It could make sense to push the limit further back to vcs to also prevent computing or allocating memory for huge diffs.
diffs: inline prepare() into __init__ and make the result available as .parsed
Make it more clear what the DiffProcessor is: Something that works on a raw diff as input, mainly compute when initialized, and returns an object where the result is available in different ways.
diffs: avoid extra copy of diff when splitting into files
Instead of allocating memory for an extra copy of the whole raw diff, just use buffer() to give read-only string views of the relevant sections of the big diff string given as input.
diffs: cleanup of variable naming around cut_off_limit
A brief summary of this area:
The base controller sets self.cut_off_limit from config and is used for diffs, unless controllers are given a fulldiff query parameter. In a few cases, these are passed to templates as c.cut_off_limit or c.fulldiff . Also, if the diff function returns a LimitedDiffContainer, c.limited_diff is set so the UI can report the data set is partial.
templates: back out the DataTables paging disabling from c5bff92d5084
Lessons learned: * It was not sufficiently tested with gravatars. * It was not sufficiently tested on Chrome - Firefox seems to handle some big pages better. * It is unclear how big amounts of data we want to optimize for, but this regressed too much for some cases.
ini: drop insertion of header comments in generated ini files
The header comments were kind of redundant and could easily get out of sync. Also, we are moving towards just generating files and don't need this and don't want to maintain it.
ini: add support for adding extra entries to sections
When adding entries to an existing section, assume that comments and empty lines *before* a section header belongs to that section. That is an approximation; not always entirely correct, but the best we can come up with.