By using this site, you agree to have cookies stored on your device, strictly for functional purposes, such as storing your session and preferences.

Dismiss

Add basic diffs

roundabout,
created on Monday, 1 April 2024, 14:46:57 (1711982817), received on Wednesday, 31 July 2024, 06:54:44 (1722408884)
Author identity: vlad <vlad.muntoiu@gmail.com>

c259006d0227ada7570808f35e0b17356da34edf

app.py

@@ -81,6 +81,10 @@ worker = celery_integration.init_celery_app(app)

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            repositories = flask.Blueprint("repository", __name__, template_folder="templates/repository/")
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        app.jinja_env.add_extension("jinja2.ext.do")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        app.jinja_env.add_extension("jinja2.ext.loopcontrols")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        app.jinja_env.add_extension("jinja2.ext.debug")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            @app.context_processor
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            def default():
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -610,7 +614,9 @@ def repository_commit(username, repository, sha):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                repo_data = Repo.query.filter_by(route=f"/{username}/{repository}").first()
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                files = git_command(os.path.join(server_repo_location, ".git"), None, "diff-tree", "-r",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                "--name-only", "--no-commit-id", sha).decode().split("\n")
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                "--name-only", "--no-commit-id", sha).decode().split("\n")[:-1]
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            print(files)
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                return flask.render_template(
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        "repo-commit.html",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        

@@ -619,7 +625,7 @@ def repository_commit(username, repository, sha):

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        remote=f"http{'s' if config.suggest_https else ''}://{config.BASE_DOMAIN}/git/{username}/{repository}",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        is_favourite=get_favourite(flask.session.get("username"), username, repository),
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                        diff={file: git_command(os.path.join(server_repo_location, ".git"), None, "diff",
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            str(sha), str(sha) + "^", file).decode().split("\n") for
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                                            str(sha) + "^!", "--", file).decode().split("\n") for
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                              file in files}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                )
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

static/efficient-ui/THEME.css

@@ -33,7 +33,7 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    normal /* variant */
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    300 /* weight */
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    normal /* stretch */
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                14.2px/16px /* size / line height */
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                14.5px/20px /* size / line height */
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    "Roboto Mono", "Noto Sans Mono", "Noto Mono", "Source Code Pro", "Source Code", "source-pro-code", Cousine, Consolas, monospace /* family */
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    ;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                --keyboard-font: /* keyboard */
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

static/style.css

@@ -395,3 +395,14 @@ del {

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                color: var(--color-deletion-text);
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                text-decoration: none;
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            }
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .interrupt-top {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            --mask: conic-gradient(from 135deg at top, #0000, #000 0 90deg,#0000 90deg) 50%/16px 100%;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            padding-top: calc(var(--padding-code) + 8px);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            -webkit-mask: var(--mask);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    mask: var(--mask);
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        .diff-position {
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            text-align: center;
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        }
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                            
                                

templates/repository/repo-commit.html

@@ -8,10 +8,19 @@

                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            {% block content %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            <x-vbox>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                <x-frame style="--width: 896px;" class="flexible-space">
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                {% for line in diff | decode | split("\n") %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% if line[0] == "+" %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        <ins>{{ line[1:] }}</ins>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% endif %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                {% for file in diff %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    <h2>{{ file }}</h2>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% set vars = namespace(i=0) %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% for line in diff[file] %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        {% if line.startswith("@@") %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                            {% break %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        {% endif %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                        {% set vars.i = vars.i+1 %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% endfor %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    <h4 class="diff-position">{{ diff[file][vars.i] }}</h4>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    {% set vars.i = vars.i+1 %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                                    <pre class="interrupt-top">{% for line in diff[file][vars.i:] %}
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                        {% if line[0] == "+" %}<ins>{{ line }}</ins>{% elif line[0] == "-" %}<del>{{ line }}</del>{% else %}{{ line }}{% endif %}{% endfor %}</pre>
                                        
                                        
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                    {% endfor %}
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                                </x-frame>
                                        
                                        
                                            
                                            
                                            
                                            
                                        
                                    
                                
                                
                                
                            
                                
                                    
                                        
                                            
                                            </x-vbox>