castiron / didh

Debates in the Digital Humanities
GNU General Public License v3.0
38 stars 12 forks source link

[BUGFIX]: annotation overlap text (fixes issue #3) #12

Closed lrcg closed 4 years ago

lrcg commented 8 years ago

Description

The online version of the book has many interactive features, one of which is an annotation bar to the left of the text which is essentially a vertical histogram of the number of annotations for a particular sentence. In the introduction to the book, The Digital Humanities Moment by Matthew K. Gold, the annotation bar overlaps the text in several places. This was noted in issue #3 reported more than a year ago.

Analysis

The position of the <span/> comprising the annotation bar is hardcoded as -100px in the CSS:

.annotation{
    display:    block;
    width:      5px;
    height:     10px;
    background: #02adef;
    position:   absolute;
    left:       -100px;
    overflow:   visible;
}

This is the source of the bug.

The JS app sets the width of each span to illustrate the number of annotations. Gold's essay, being the first, has been heavily annotated with some sentences garnering more than 100 annotations. There is no limit set for the width, however, so when the comment count is (> 100), the annotation will begin to overlap the text.

Solution

This fix adds a new property (annotations_max_n) to the Text::as_json method which is simply the highest number of annotations for a sentence in that text. The value of this property is then used to scale the annotation bar between 1 and 100px, as set in the CSS, and is also used to scale the opacity between 0 and 1. Currently, there is no upper bound for the opacity. Although values outside the 0 to 1 range are not errors, they have no additional effect, either.

Misc

Two important notes regarding this pull request.

  1. I do not have access to a working instance, so this is not tested. I believe it should work, though.
  2. I commented out a method and a single line of code, both of which appear to be unused in any way. As I can not test the changes, I have left them commented out with a note that they appear unused.
zdavis commented 8 years ago

Hey, thanks for the pull request. It's great to get a fix like this from the book's community of readers! At first glance, it looks good to me, but Lucas or I will apply the patch and review it more closely in the next day or so.

lrcg commented 8 years ago

Thanks for considering it. I hope it works. I would love to work on other CIC projects some time!

lrcg commented 8 years ago

@zdavis Any chance of getting a copy of the chef recipes? I'm happy to spin up an instance and test it out myself, but guessing the dependencies takes a long time.

zdavis commented 8 years ago

The README on this project is woefully outdated, but should be receiving an update soon, as @blnkt is actively working on this project right now, in advance of the second DH Debates volume being released in the near future. We don't use Chef anymore at Cast Iron (switched to Puppet a few years ago).

At this point, this is more or less a regular rails project. You should be able to clone the repo, run bundle install, setup a connection to a Postgres database, and be off the the races. You'll want to be sure to seed the database, then run rake texts:import to pull in the texts.

The one tricky part is the Java dependency for the NLP piece. There are some ruby java bindings that can be tricky to install if there's a Java mismatch. Give it a go, though, and let us know if you run into trouble. @lthurston or @blnkt might have insight on this, as they've spun this one up more recently than I have.

lthurston commented 8 years ago

@blnkt Just did this the other day. I'll see if he remembers the specifics of what he did. I chose to cringe and avert my eyes.

lrcg commented 8 years ago

@lthurston No worries. I was just trying to learn more about CIC projects and see if I could get more involved.

lrcg commented 8 years ago

@zdavis I'll have a go at the weekend. It would be interesting to dig into it a bit. Any chance of helping out on version 2? The development doesn't seem to be happening here.

blnkt commented 8 years ago

Yes, hello. I rewrote the ReadME to include some set-up info for development. @lrcg, I'll include the text from the ReadME below and please let me know if it answers any/all of the questions in terms of getting going on this project.

Thanks.

Debates in the Digital Humanities

General Dev practices

Before installing gems with Bundler verify you are running Java 6. If you run java -version you should see

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-468-11M4833)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-468, mixed mode)

Java 6 legacy can be download for OSX Capitan here. After installing Java 6, bundle install as normal.

Seed data with rake db:seed and then parse the sample texts using rake texts:import

Run the rails server using shell script: script/server May access rails cli using 'script/rails

zdavis commented 8 years ago

One of these days soon, we need to make the Ruby Java bindings work with recent versions of Java (if possible)

lrcg commented 8 years ago

@blnkt Thanks for the information! I'll give it a try soon.

@zdavis Great! Please let me know what I can do to help. I'd love to hone my skills on some CIC projects sometime.