Project

General

Profile

Wordpress » History » Version 4

Denis 'GNUtoo' Carikli, 02/26/2024 04:57 PM
Use script instead to automatize things

1 1 Denis 'GNUtoo' Carikli
h1. Wordpress
2
3
h2. Plugins
4
5
| Plugin                             | License | Free software directory review page                                                    |
6
| Akismet Anti-spam: Spam Protection |         |                                                                                        |
7
| Companion Auto Update              |         |                                                                                        |
8
| Post Notification by Email         | GPLv2+  | "Post_Notification_by_Email":https://directory.fsf.org/wiki/Post_Notification_by_Email |
9
10
Replicant also has a modified Post Notification by Email modified by Paul Kocialkowski from version Version 4.1.2 of Post Notification by Email.
11 3 Denis 'GNUtoo' Carikli
12
h2. Research on markdown with Wordpress.
13
14
h2. Using markdown with haunt.
15
16
There is work in progress to migrate the Wordpress blog to a static website that uses markdown. 
17
18
Haunt is a good candidate for that and there was some work to try it out in the "contrib/GNUtoo/haunt-blog":https://git.replicant.us/contrib/GNUtoo/infrastructure/haunt-blog/ repository.
19
20
So until this work is finished, we can still use that work to work on blog posts with a markdown format and then convert that markdown to html suitable for Wordpress.
21
22 4 Denis 'GNUtoo' Carikli
To do that, once the HTML page has been created, you can this script to prettify it and rearrange the paragraphs not to have line breaks inside (which are interpreted as line breaks in Wordpress):
23
24 1 Denis 'GNUtoo' Carikli
<pre>
25
#!/usr/bin/env python3
26 4 Denis 'GNUtoo' Carikli
# encoding: utf-8
27
# Copyright (C) 2020, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
28
#
29
# This program is free software: you can redistribute it and/or modify
30
# it under the terms of the GNU Affero General Public License as published by
31
# the Free Software Foundation, either version 3 of the License, or
32
# (at your option) any later version.
33
#
34
# This program is distributed in the hope that it will be useful,
35
# but WITHOUT ANY WARRANTY; without even the implied warranty of
36
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
37
# GNU Affero General Public License for more details.
38
#
39
# You should have received a copy of the GNU Affero General Public License
40
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
41 1 Denis 'GNUtoo' Carikli
42 4 Denis 'GNUtoo' Carikli
import bs4
43
import enum
44
import os
45
import re
46
import sys
47
48
def usage(progname):
49
    print("{} path/to/file.html".format(progname))
50
    sys.exit(1)
51
52
def fixup_html(html):
53
    open_p = 0
54
    buf = [None]  * 4
55
    for c in html:
56
        buf[0] = buf[1]
57
        buf[1] = buf[2]
58
        buf[2] = buf[3]
59
        buf[3] = c
60
61
        if buf[1] == '<' and buf[2] == 'p' and buf[3] == '>':
62
            open_p += 1
63
        if buf[0] == '<' and buf[1] == '/' and buf[2] == 'p' and buf[3] == '>':
64
            open_p -= 1
65
        
66
        if c == '\n' and open_p > 0:
67
            pass
68
        else:
69
            print(c, end='')
70
def main():
71
    if len(sys.argv) != 2:
72
        usage(sys.argv[0])
73
74
    html_file_path = sys.argv[1]
75
76
    with open(html_file_path) as html_file:
77
        soup = bs4.BeautifulSoup(html_file, 'html.parser')
78
        pretty_html = soup.prettify()
79
        fixup_html(pretty_html)
80
81
            
82
if __name__ == '__main__':
83
    main()
84 3 Denis 'GNUtoo' Carikli
</pre>
85
86 4 Denis 'GNUtoo' Carikli
87
88 3 Denis 'GNUtoo' Carikli
This produces something like that:
89
<pre>
90
<!DOCTYPE html>
91
<head>
92
 <meta charset="utf-8"/>
93
 <link href="static/twentyeleven-style-20231107.css" rel="stylesheet"/>
94
 <title>
95
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences. — Replicant
96
 </title>
97
</head>
98
<body>
99
 <header>
100
  <nav id="access">
101
   <ul>
102
    <li>
103
     <a href="https://www.replicant.us">
104
      Home
105
     </a>
106
    </li>
107
    <li>
108
     <a href="https://blog.replicant.us">
109
      Blog
110
     </a>
111
    </li>
112
    <li>
113
     <a href="https://redmine.replicant.us/projects/replicant/wiki">
114
      Wiki
115
     </a>
116
    </li>
117 1 Denis 'GNUtoo' Carikli
    <li>
118 3 Denis 'GNUtoo' Carikli
     <a href="https://redmine.replicant.us/projects/replicant/issues">
119
      Tracker
120
     </a>
121
    </li>
122
    <li>
123
     <a href="https://redmine.replicant.us/projects/replicant/boards">
124 1 Denis 'GNUtoo' Carikli
      Forums
125
     </a>
126 3 Denis 'GNUtoo' Carikli
    </li>
127
   </ul>
128
  </nav>
129
 </header>
130
 <h2>
131
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences.
132
 </h2>
133
 <div>
134
  <h1>
135
   Replicant current status:
136
  </h1>
137 4 Denis 'GNUtoo' Carikli
  <p>   The last Replicant release is still based on Android 6.0.  </p>
138
  <p>   In the previous years, a lot of work was done to make the Galaxy SIII(GT-I9300) usable with an upstream kernel, both on graphics and on themodem.  </p>
139 3 Denis 'GNUtoo' Carikli
[...]
140 4 Denis 'GNUtoo' Carikli
    <p>     The main maintainer of Replicant also met with PaulKocialkowski. Before that meeting he thought that on GNU/Linux the     <a href="https://gitlab.com/mobian1/eg25-manager">      eg25-manager program     </a>     forthe Pinephone only did simple things like setting up udev rules andhad simple hacks to make the modem work fine, and he thought thatall stability issues were to be handled by Modem Managerinstead. But the EC 25 Manager is might also be monitoring the modemand restarting it when it crashed. This could explain modemstability issues with Android / GloDroid on PinePhones with 3GiB ofRAM. And so the fix would be to port / reimplement that feature tomake this model usable.    </p>
141 3 Denis 'GNUtoo' Carikli
   </li>
142
  </ul>
143
 </div>
144
</body>
145
</pre>
146
147
So first add the article title in wordpress, and then you can start switch to the code editor and paste the article starting right after the header and first top level title:
148
<pre>
149
<!DOCTYPE html>
150
<head>
151
 <meta charset="utf-8"/>
152
 <link href="static/twentyeleven-style-20231107.css" rel="stylesheet"/>
153
 <title>
154
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences. — Replicant
155
 </title>
156
</head>
157
<body>
158
 <header>
159
  <nav id="access">
160
   <ul>
161
    <li>
162
     <a href="https://www.replicant.us">
163
      Home
164
     </a>
165
    </li>
166
    <li>
167
     <a href="https://blog.replicant.us">
168
      Blog
169
     </a>
170
    </li>
171
    <li>
172
     <a href="https://redmine.replicant.us/projects/replicant/wiki">
173
      Wiki
174
     </a>
175
    </li>
176
    <li>
177
     <a href="https://redmine.replicant.us/projects/replicant/issues">
178
      Tracker
179
     </a>
180
    </li>
181
    <li>
182
     <a href="https://redmine.replicant.us/projects/replicant/boards">
183
      Forums
184
     </a>
185
    </li>
186
   </ul>
187
  </nav>
188
 </header>
189
 <h2>
190
  Replicant status and report of the 37C3 and FOSDEM 2024 conferences.
191
 </h2>
192
 <div>
193
</pre>
194
195
Also ommit the end:
196
<pre>
197
 </div>
198
</body>
199 1 Denis 'GNUtoo' Carikli
</pre>