aboutsummaryrefslogtreecommitdiff
path: root/pages/article.sh
blob: c2398f7c520caec26fa1acf50c73986ce146951c (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
#!/bin/bash

COMMENTS_FOLDER="$SCRIPT_DIR/pages/$REQUEST_URI/comments" source $SCRIPT_DIR/components/comments.sh

source $SCRIPT_DIR/utils/parse-article.sh

if [ $? -gt 0 ]; then
  STATUS=404
  cat <<ERR
<p class="err-404">404: $ARTICLE_FILE: Arquivo ou diretório inexistente</p>
ERR
  exit 0
fi

cat <<ARTICLE
<article class="container">
  <section>
    <div class="post-header">
      <h4 class="post-title">$ARTICLE_FILE</h4>
      <small>$ARTICLE_BYTES</small> <br/>
      <time>$ARTICLE_TIME</time> <br/>

      <ul class="tags">
        $(
          for i in "${ARTICLE_TAGS[@]}"; do
            echo "<li class="tag">$i</li>"
          done
        )
      </ul>
    </div>

    <div class="post-content">
      <p>
        ${ARTICLE_CONTENT}
      </p>
    </div>
  </section>

  <br />
  <hr />
  <section>
    <h4>Deixei o seu comentário sobre este artigo</h4>
    <form method="POST" action="/post" enctype="multipart/form-data">
      <input type="hidden" name="destination" value="$REQUEST_URI/comments" />
      <input type="hidden" name="redirect_to" value="$REQUEST_URI" />

      <label for="name">Nome</label>
      <input id="name" type="text" name="name" value="Anônimo" />
      <br/>

      <label for="email">Email</label>
      <input id="email" type="email" name="email" />
      <br/>

      <label for="message">Mensagem *</label>
      <textarea id="message" name="message" required></textarea>
      <small>Campos marcados com asterisco (*) são obrigatórios</small>
      <br />

      <br />
      <label for="file-attachment">Anexar arquivo</label>
      <input id="file-attachment" type="file" name="attachment" />

      <input type="submit" value="Enviar" />
    </form>

  </section>
</article>

<div class="container">
  <hr />
  <h4 style="text-align">Discussão</h4>
  <br />

  $(
    if [ -n "$PARSED_COMMENTS" ]; then
      echo "$PARSED_COMMENTS"
    else
      echo '<p style="text-align">Sem mensagens para mostrar.</p>'
    fi
  )
</div>
ARTICLE