summaryrefslogtreecommitdiff
path: root/projects/index.php
blob: 1f6a7dca48c0c38fb4a9fac210f1f8308f8b65a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php $title = "Projects"; require $_SERVER['DOCUMENT_ROOT'] . "/includes/main.php";

$base = array_keys($_GET)[0] ?? null;

if (isset($base)) {
    $parts = array_values(array_filter(explode("/", $base), function ($i) { return trim($i) !== ""; }));
    $name = $parts[0];

    $projects = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/projects.json"), true);

    if (!in_array($name, array_map(function ($i) { return $i["id"]; }, $projects))) {
        header("Location: /projects");
        die();
    }

    $project = array_values(array_filter($projects, function ($i) use ($name) {
        return $i["id"] === $name;
    }))[0];

    $title = $project["display_name"] . " | " . $title;
} else {
    $parts = null;
}

require $_SERVER['DOCUMENT_ROOT'] . "/includes/header.php";

?>

<div class="container">
    <?php if (isset($parts)): ?>
    <br><br>

    <div class="project-page">
        <div id="project-description">
            <?php if (isset($project["readme"])): ?>
            <?php

            require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/Parsedown.php";
            $Parsedown = new Parsedown();

            echo $Parsedown->text($project["readme"]);

            ?>
            <?php else: ?>
            <h1><?= $project["display_name"] ?></h1>
            <p><?= trim($project["description"]) === "" ? "<span class='text-muted'>This project does not have a description.</span>" : strip_tags($project["description"]) ?></p>
            <?php endif; ?>
            <script>
                document.querySelectorAll("#project-description table").forEach((i) => {
                    i.classList.add("table");
                });
            </script>
        </div>

        <div>
            <a href="/projects" class="fancy-card-hidden"><div class="fancy-card">
                <div class="fancy-card-outer">
                    <div class="card">
                        <div class="card-body">
                            <img alt="" src="/assets/icons/back.svg" style="width: 24px; height: 24px; vertical-align: middle;">
                            <span style="vertical-align: middle;">Back to projects list</span>
                        </div>
                    </div>
                </div>
            </div></a>

            <div class="fancy-card-group">
                <a href="<?= $project["source"] ?>" target="_blank" class="fancy-card-hidden"><div class="fancy-card">
                    <div class="fancy-card-outer">
                        <div class="card">
                            <div class="card-body">
                                <img alt="" src="/assets/icons/code.svg" style="width: 24px; height: 24px; vertical-align: middle;">
                                <span style="vertical-align: middle;">Source code</span>
                            </div>
                        </div>
                    </div>
                </div></a>
                <a href="<?= $project["website"] ?>" target="_blank" class="fancy-card-hidden"><div class="fancy-card">
                    <div class="fancy-card-outer">
                        <div class="card">
                            <div class="card-body">
                                <img alt="" src="/assets/icons/website.svg" style="width: 24px; height: 24px; vertical-align: middle;">
                                <span style="vertical-align: middle;">Website</span>
                            </div>
                        </div>
                    </div>
                </div></a>
            </div>

            <div class="fancy-card fancy-card-unclickable">
                <div class="fancy-card-outer" style="padding-left: 0 !important;padding-right: 0 !important;">
                    <div class="card">
                        <div class="card-body">
                            <div class="languages">
                                <h5>Languages</h5>
                                <?php $total = array_reduce($project["languages"], function ($a, $b) {
                                    return $a + $b;
                                }); foreach ($project["languages"] as $name => $lines): ?>
                                    <div class="language">
                                        <span style="background-color: <?= getColorFromLanguage($name) ?>; width: 16px; height: 16px; display: inline-block; border-radius: 100%; vertical-align: middle;"></span>
                                        <span style="vertical-align: middle; margin-left: 2px;"><?= $name ?></span>
                                        <span style="float: right;" class="text-muted"><?= round(($lines / $total) * 100, 2) ?>%</span>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php else: ?>
    <br><br>

    <h1>Our projects</h1>
    <p>We more than often make our own software, and in most cases this software gets its source code released to the public. Below is a list of all projects for which we've released the source code for all to use.</p>

    <div class="fancy-card-container fancy-card-grid">
        <?php

        foreach (getProjectsList() as $project): ?>
        <div class="fancy-card-outer">
            <a class="fancy-card" href="/projects/?/<?= $project["id"] ?>">
                <div class="card">
                    <div class="card-body">
                        <div class="fancy-card-header">
                            <h4 class="card-title" style="margin-bottom: 15px;">
                                <img alt="" style="border-radius:5px;vertical-align: middle; width: 30px; height: 30px;" src="<?= $project["icon"] ?? (file_exists($_SERVER['DOCUMENT_ROOT'] . "/assets/projects/" . $project["id"] . ".png") ? "/assets/projects/" . $project["id"] . ".png" : "/assets/icons/project.svg") ?>">
                                <span style="vertical-align: middle; margin-left: 5px;"><?= $project["display_name"] ?></span>
                            </h4>
                        </div>

                        <div class="fancy-card-body">
                            <p><?= trim($project["description"]) === "" ? "<span class='text-muted'>This project does not have a description.</span>" : strip_tags($project["description"]) ?></p>
                        </div>

                        <div class="fancy-card-footer">
                            <p style="margin-bottom: 0;" class="text-muted"><?= timeAgo($project["update"], true) ?><?php if (count($project["languages"]) > 0): ?> · <?= implode(", ", array_keys($project["languages"])) ?><?php endif; ?></p>
                        </div>
                    </div>
                </div>
            </a>
        </div>
        <?php endforeach; ?>
    </div>
    <?php endif; ?>
</div>

<?php require $_SERVER['DOCUMENT_ROOT'] . "/includes/footer.php"; ?>