Download raw body.
gotwebd: class-ify some CSS selector and close a couple of divs
gotwebd: class-ify some CSS selector and close a couple of divs
gotwebd: class-ify some CSS selector and close a couple of divs
On Tue, Aug 09, 2022 at 05:30:27PM +0200, Omar Polo wrote:
> Tracey Emery <tracey@traceyemery.net> wrote:
> > On Sat, Aug 06, 2022 at 06:41:24PM +0200, Omar Polo wrote:
> > > i noticed that gotwebd uses a lot of ids for element that are present
> > > multiple times in a page. Diff below moves all such ids to classes
> > > (well, only the one that I've spotted so far.) We could even consider
> > > to move everything from ids to classes to simplify the work in the
> > > future.
> > >
> > > While here i've also deleted some unused css (or maybe i should keep
> > > it for the future?) and fixed two HTML errors: one extra div closed in
> > > one place and one missing div closed in another place.
> > >
> > > I'm running my gotwebd with this applied and seems fine.
> > >
> >
> > ok.
>
> wooops, i've noticed only now that this broke the alternate coloring
> of the files in the tree view. The issue is that now we output
> multiple class="" attributes and only the first one is used.
>
> However, instead of fixing it by constructing the right class=""
> attribute, what about doing something like this?
Sure, if that works across browsers, go for it. It's a cleaner solution.
>
> diff d878a24ff7bcf664f95a19c60627a406bbc7a5da refs/heads/main
> commit - d878a24ff7bcf664f95a19c60627a406bbc7a5da
> commit + 601ade2d2def2be51d3f2c8e6b0c121e6a4d0337
> blob - 792e8e19e303eed4e803422c638c1c557e713417
> blob + 10508310cce72f5c7f5a09c6d456644d90a35343
> --- gotwebd/files/htdocs/gotwebd/gotweb.css
> +++ gotwebd/files/htdocs/gotwebd/gotweb.css
> @@ -50,13 +50,6 @@ body {
> color: blue;
> }
>
> -.back_white {
> - background-color: #ffffff;
> -}
> -.back_lightgray {
> - background-color: #d8f3ef;
> -}
> -
> #logo {
> height: 50px;
> }
> @@ -649,7 +642,11 @@ body {
> clear: left;
> float: left;
> width: 100%;
> + background-color: #d8f3ef;
> }
> +.tree_wrapper:nth-child(even) {
> + background-color: #ffffff;
> +}
> .tree_line {
> clear: left;
> float: left;
> blob - afab0d2143e87ec521a920327cbd9288cd97069f
> blob + d0b66921ca30028ef77855bc25dc55e1492de971
> --- gotwebd/got_operations.c
> +++ gotwebd/got_operations.c
> @@ -831,8 +831,8 @@ got_output_repo_tree(struct request *c)
> struct repo_dir *repo_dir = t->repo_dir;
> char *id_str = NULL;
> char *path = NULL, *in_repo_path = NULL, *build_folder = NULL;
> - char *modestr = NULL, *name = NULL, *class = NULL;
> - int nentries, i, class_flip = 0;
> + char *modestr = NULL, *name = NULL;
> + int nentries, i;
>
> TAILQ_INIT(&refs);
>
> @@ -917,22 +917,6 @@ got_output_repo_tree(struct request *c)
> }
> }
>
> - if (class_flip == 0) {
> - class = strdup("back_lightgray");
> - if (class == NULL) {
> - error = got_error_from_errno("strdup");
> - goto done;
> - }
> - class_flip = 1;
> - } else {
> - class = strdup("back_white");
> - if (class == NULL) {
> - error = got_error_from_errno("strdup");
> - goto done;
> - }
> - class_flip = 0;
> - }
> -
> name = strdup(got_tree_entry_get_name(te));
> if (name == NULL) {
> error = got_error_from_errno("strdup");
> @@ -950,13 +934,8 @@ got_output_repo_tree(struct request *c)
> "<div class='tree_wrapper'>\n") == -1)
> goto done;
>
> - if (fcgi_gen_response(c, "<div class='tree_line' "
> - "class='") == -1)
> + if (fcgi_gen_response(c, "<div class='tree_line'>") == -1)
> goto done;
> - if (fcgi_gen_response(c, class) == -1)
> - goto done;
> - if (fcgi_gen_response(c, "'>") == -1)
> - goto done;
>
> if (fcgi_gen_response(c, "<a class='diff_directory' "
> "href='?index_page=") == -1)
> @@ -989,13 +968,8 @@ got_output_repo_tree(struct request *c)
> if (fcgi_gen_response(c, "</div>\n") == -1)
> goto done;
>
> - if (fcgi_gen_response(c, "<div class='tree_line_blank' "
> - "class='") == -1)
> + if (fcgi_gen_response(c, "<div class='tree_line_blank'>") == -1)
> goto done;
> - if (fcgi_gen_response(c, class) == -1)
> - goto done;
> - if (fcgi_gen_response(c, "'>") == -1)
> - goto done;
> if (fcgi_gen_response(c, " ") == -1)
> goto done;
> if (fcgi_gen_response(c, "</div>\n") == -1)
> @@ -1015,13 +989,8 @@ got_output_repo_tree(struct request *c)
> if (fcgi_gen_response(c,
> "<div class='tree_wrapper'>\n") == -1)
> goto done;
> - if (fcgi_gen_response(c, "<div class='tree_line' "
> - "class='") == -1)
> + if (fcgi_gen_response(c, "<div class='tree_line'>") == -1)
> goto done;
> - if (fcgi_gen_response(c, class) == -1)
> - goto done;
> - if (fcgi_gen_response(c, "'>") == -1)
> - goto done;
>
> if (fcgi_gen_response(c,
> "<a href='?index_page=") == -1)
> @@ -1066,13 +1035,8 @@ got_output_repo_tree(struct request *c)
> if (fcgi_gen_response(c, "</div>\n") == -1)
> goto done;
>
> - if (fcgi_gen_response(c, "<div class='tree_line_blank' "
> - "class='") == -1)
> + if (fcgi_gen_response(c, "<div class='tree_line_blank'>") == -1)
> goto done;
> - if (fcgi_gen_response(c, class) == -1)
> - goto done;
> - if (fcgi_gen_response(c, "'>") == -1)
> - goto done;
>
> if (fcgi_gen_response(c,
> "<a href='?index_page=") == -1)
> @@ -1166,8 +1130,6 @@ got_output_repo_tree(struct request *c)
> name = NULL;
> free(modestr);
> modestr = NULL;
> - free(class);
> - class = NULL;
> }
> done:
> free(id_str);
> @@ -1175,7 +1137,6 @@ done:
> free(modestr);
> free(path);
> free(name);
> - free(class);
> got_ref_list_free(&refs);
> if (commit)
> got_object_commit_close(commit);
>
--
Tracey Emery
gotwebd: class-ify some CSS selector and close a couple of divs
gotwebd: class-ify some CSS selector and close a couple of divs
gotwebd: class-ify some CSS selector and close a couple of divs