Coder Social home page Coder Social logo

hypothesis / bouncer Goto Github PK

View Code? Open in Web Editor NEW
47.0 15.0 26.0 1.79 MB

The "hyp.is" service that takes a user to a URL with Hypothesis activated

License: BSD 2-Clause "Simplified" License

Python 71.70% JavaScript 14.32% CSS 1.61% Makefile 6.22% Shell 2.12% Dockerfile 1.03% Jinja 3.00%
hypothesis annotation

bouncer's People

Contributors

acelaya avatar chdorner avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dmfine avatar indigobravo avatar jon-betts avatar judell avatar lyzadanger avatar marcospri avatar nickstenning avatar robertknight avatar seanh avatar sheetaluk avatar xolotl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bouncer's Issues

Support group: as a parameter

In #48 @robertknight says:

group:{pubid} - No, not yet. I do understand that this would be very useful. It does surface some issues that we'll need to address or have a reasonable idea of what we might do later, such as how to handle the case where the current user is not a member of the group and will we ever support multiple groups. Could you file an issue?

Questions:

What if the current user is not a member of the group

If they follow a hyp.is link that specifies a group they're not a member of, they should be taken to the indicated page, but the target group annotations obviously cannot and presumably should not be shown to them. For now, I don't think they should auto-join the group, though I can imagine that groups which are more open might be able to be configured to allow auto-joining.

In the event that they're not a member, perhaps a card or alert is shown that says "you don't have permission to view annotations in group XXX".

Will we ever support multiple groups (being specified as params)

Possibly-- though I imagine the overwhelming use case here is a single group. For sure multiple groups is not a first requirement. Do we need to determine now?

502 error from h. host

Hope I'm in the right place:
image
Let me know if there is somewhere else I should send such alerts.

Bouncer links not activating the Chrome extension when group is Public

Summary

If you follow a bouncer link in a browser where the Chrome extension is installed, the extension doesn't activate once the link resolves.

Steps to reproduce

  1. Get a Bouncer link for the Public channel for a PDF or web page. Three that we've tested with are:
  1. In a browser where the Chrome extension is installed, follow that link

Expected behavior

The Chrome extension activates and the sidebar opens

Actual behavior

The extension is not activated. You have to manually turn it on:

Screen Shot 2020-04-02 at 5 12 05 PM

Notes

Strangely, we don't see this problem with private groups. You can join this private group and it'll work properly. See:

It's also working properly for publisher groups. See:
https://hyp.is/go?url=https%3A%2F%2Fmodernismmodernity.org%2Fforums%2Fposts%2Fresponses-responses-special-issue-weak-theory&group=q9iV3JLd

...so this appears to be isolated to the Public channel.

Check chrome.runtime.lastError

Rob: Looking at the JS code, I do see an issue that we're not checking chrome.runtime.lastError in the sendMessage callback

bouncer doesn't relay url parameters to via?

Logo and background sometimes broken in Safari

When visiting a bouncer link in Safari, I often see a blank white page and a broken image icon, instead of the Hypothesis logo. Example link: http://hyp.is/d0bL8J45Ee2jgp8SioFyUQ/arxiv.org/pdf/2203.02155.pdf. The logo loads correctly in Chrome and Firefox.

If I disable JavaScript in a new tab via Develop -> Disable JavaScript and then visit http://hyp.is/d0bL8J45Ee2jgp8SioFyUQ/arxiv.org/pdf/2203.02155.pdf, the logo and styles load correctly. I'm guessing what is happening is that when the immediate redirect to Via happens after the page loads, it causes the other resources on the page not to be loaded.

Direct users to Atlassian extension if annotation is associated with atlassian.hypothes.is authority

Background

Praecipio are building an integration between Confluence and Hypothesis. This uses a custom version of the Hypothesis Chrome extension which users log into using their Atlassian ID. Users see groups that correspond to the Spaces they belong to in Confluence. Annotations that are created get saved to Hypothesis and also posted as entries in Confluence pages.

Behind the scenes, this extension communicates with a custom H API endpoint which is a proxy server that wraps the real H API to customize the login process and "decorate" API calls with additional functionality related to the Confluence integration. The user accounts, groups and annotations used with this extension are all associated with the atlassian.hypothes.is authority in h.

See the #atlassian-demo channel in Slack for more details.

Problem

We want to support sharing links for these annotations, similar to the hyp.is links for regular Hypothesis users. These sharing links will be included in the entries posted in Confluence, so users have a convenient way to view the link in context.

The bouncer service currently directs users either to the regular Hypothesis Chrome extension or Via, depending on whether they have the extension installed. The regular Hypothesis Chrome extension assumes first party user accounts, which is not the case for these annotations. Via also won't work for the same reason.

Constraints

We'll need a solution we can quickly deploy for an upcoming demo. We will also need something we can run longer term.

Possible solutions

1. Run a separate instance of the bouncer service specifically for Atlassian users

The hyp.is server allows configuring the Chrome extension and Via URL via environment variables. We could run a new instance of bouncer which modifies this configuration. Sharing links in annotations would somehow need to be modified to reference this new instance. This could be done by the proxy server, although that wouldn't work for any system or client fetching annotations from the API directly rather than going via the proxy server.

Pros:

  • Reduces amount of configurability required within the bouncer service

Cons:

  • This adds additional infrastructure that we have to run and deploy new updates to
  • We have to find a way to change the incontext_link field on annotations to point at the custom service. There is currently nowhere in h to configure authority-wide settings.
  • We'll still need to make some changes to bouncer to handle the unavailability of Via for these annotations, and also customize attributes such as the logo

2. Add ability to configure behavior of bouncer depending on annotation authority

Allow some basic configuration of how Bouncer directs users depending on the annotation's authority. The minimal configurability we would need for this project is:

  1. Direct users to a different extension if the annotation is associated with the atlassian.hypothes.is authority
  2. Provide a fallback if the user does not have the Atlassian extension installed. This could be a redirect to a static URL which tells the user how to install the extension. In future we might want the ability to direct the user to a custom Via-like service.

We don't add new authorities often, so it would be fine if this configuration was stored in a static file.

Pros:

  • Makes it easier to support similar use cases in future

Cons:

  • Requires more configurability in bouncer

Attempt to upgrade or fix `pyramid_jinja2`

For: hypothesis/product-backlog#1199

It looks like pyramid_jinja2 only support 3.6 according to it's classifiers: https://pypi.org/project/pyramid-jinja2/

The docs mention adding 3.7 support and looking at the repo there is evidence of 3.8 support at least: https://github.com/Pylons/pyramid_jinja2

We should work out what the correct version is and try and work with the maintainers to fix the classifiers if possible.

This is holding up our upgrades to a higher version of Python.

Handle document URIs that already have a # on them

Looking at our production API, some annotated document URIs already have # fragment identifiers in them. Based on a quick look at 100,000 production annotations coming out of the hypothes.is API (not directly out of Elasticsearch, but I think it's the same) these mostly seem to end in # alone with no value, e.g. http://www.thetimes.co.uk/tto/environment/article4702412.ece# but some are #value ones.

Anyway, simply appending #annotations:<id> to that won't work, I think we need to strip these.

Link with deleted annotations fails

We don't delete annotations immediately from the search index but replace it with a {"deleted": true} body. We probably need to detect this at the beginning and then raise an error that should basically show the 404 error.

https://sentry.io/hypothesis/bouncer/issues/323267010/

KeyError: 'group'
(2 additional frame(s) were not displayed)
...
  File "pyramid/view.py", line 541, in _call_view
    response = view_callable(context, request)
  File "pyramid/config/views.py", line 353, in rendered_view
    result = view(context, request)
  File "pyramid/config/views.py", line 483, in _class_requestonly_view
    response = getattr(inst, attr)()
  File "bouncer/views.py", line 43, in annotation
    parsed_document = util.parse_document(document)
  File "bouncer/util.py", line 72, in parse_document
    group = annotation["group"]

KeyError: 'group'

URL truncation looks bad when it truncates after a .

For example given the URL https://blackboard.american.edu/bbcswebdav/pid-3280529-dt-content-rid-11942183_1/courses/WRTG-101-017-034-050-2016S/PerlemanLes_InformationIlliteracy.pdf the redirecting message will be Loading annotations forhttps://blackboard.american....`. The . followed by the &hellip; looks like four dots in a row.

Suggested solution: after truncating the string remove any trailing dots before appending the ellipsis?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.