aboutsummaryrefslogtreecommitdiff
path: root/content/posts/2021-12-30-wap-mobile-web-before-the-web.md
diff options
context:
space:
mode:
authorMitja Felicijan <m@mitjafelicijan.com>2023-07-12 18:35:08 +0200
committerMitja Felicijan <m@mitjafelicijan.com>2023-07-12 18:35:08 +0200
commit23a56bd50b04211da3cab45f72c3390711b2416b (patch)
treeab9a4a0136b4cce06dba7d853e296f682f807dbb /content/posts/2021-12-30-wap-mobile-web-before-the-web.md
parentcecb4b48a39a3558979b9c4b50e45bf605a3684e (diff)
downloadmitjafelicijan.com-23a56bd50b04211da3cab45f72c3390711b2416b.tar.gz
Moved notes and posts into subfolders
Diffstat (limited to 'content/posts/2021-12-30-wap-mobile-web-before-the-web.md')
-rw-r--r--content/posts/2021-12-30-wap-mobile-web-before-the-web.md202
1 files changed, 202 insertions, 0 deletions
diff --git a/content/posts/2021-12-30-wap-mobile-web-before-the-web.md b/content/posts/2021-12-30-wap-mobile-web-before-the-web.md
new file mode 100644
index 0000000..442943b
--- /dev/null
+++ b/content/posts/2021-12-30-wap-mobile-web-before-the-web.md
@@ -0,0 +1,202 @@
1---
2title: Wireless Application Protocol and the mobile web before the web
3url: wap-mobile-web-before-the-web.html
4date: 2021-12-30T12:00:00+02:00
5type: post
6draft: false
7---
8
9## A little stroll down the history lane
10
11About two weeks ago, I watched this outstanding documentary on YouTube
12[Springboard: the secret history of the first real
13smartphone](https://www.youtube.com/watch?v=b9_Vh9h3Ohw) about the history of
14smartphones and phones in general. It brought back so many memories. I never had
15an actual smartphone before the Android. The closest to smartphone was [Sony
16Ericsson P1](https://www.gsmarena.com/sony_ericsson_p1-1982.php). A fantastic
17phone and I broke it in Prague after a party and that was one of those rare
18occasions where I was actually mad at myself. But nevertheless, after that
19phone, the next one was an Android one.
20
21Before that, I only owned normal phones from Nokia and Siemens etc. Nothing
22special, actually. These are the phones we are talking about. Before 2007.
23Apple and Android phones didn't exist yet.
24
25These phones were rocking:
26
27- No selfie cameras.
28- ~2 inch displays.
29- ~120 MHz beast CPU's.
30- 144p main cameras.
31- But they had a headphone jack.
32
33Let's take a look at these beauties.
34
35![Old phones](/assets/wap/phones.gif)
36
37## WAP - Wireless Application Protocol
38
39Not that one! We are talking about Wireless Application Protocol and not Cardi
40B's song 😃
41
42WAP stands for Wireless Application Protocol. It is a protocol designed for
43micro-browsers, and it enables the access of internet in the mobile devices. It
44uses the mark-up language WML (Wireless Markup Language and not HTML), WML is
45defined as XML 1.0 application. Furthermore, it enables creating web
46applications for mobile devices. In 1998, WAP Forum was founded by Ericson,
47Motorola, Nokia and Unwired Planet whose aim was to standardize the various
48wireless technologies via protocols.
49[(source)](https://www.geeksforgeeks.org/wireless-application-protocol/)
50
51WAP protocol was resulted by the joint efforts of the various members of WAP
52Forum. In 2002, WAP forum was merged with various other forums of the industry,
53resulting in the formation of Open Mobile Alliance (OMA).
54[(source)](https://www.geeksforgeeks.org/wireless-application-protocol/)
55
56These were some wild times. Devices had tiny screens and data transmission rates
57were abominable. But they were capable of rendering WML (Wireless Markup
58Language). This was very similar to HTML, actually. It is a markup language,
59after all.
60
61These pages could be served by [Apache](https://apache.org/) and could be
62generated by CGI scripts on the backend. The only difference was the limited
63markup language.
64
65## WML - Wireless Markup Language
66
67Just like web browsers use HTML for content structure, older mobile device
68browsers use WML - if you need to support really old mobile phones using WML
69browsers, you will need to know about it. WML is XML-based (an XML vocabulary
70just like XHTML and MathML, but not HTML) and does not use the same metaphor as
71HTML. HTML is a single document with some metadata packed away in the head, and
72a body encapsulating the visible page. With WML, the metaphor does not envisage
73a page, but rather a deck of cards. A WML file might have several pages or cards
74contained within it.
75[(source)](https://www.w3.org/wiki/Introduction_to_mobile_web)
76
77```html
78<?xml version="1.0"?>
79<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
80<wml>
81 <card id="home" title="Example Homepage">
82 <p>Welcome to the Example homepage</p>
83 </card>
84</wml>
85```
86
87There is an amazing tutorial on [Tutorialpoint about
88WML](https://www.tutorialspoint.com/wml/index.htm).
89
90## Converting Digg to WML
91
92This task is completely useless and not really feasible nowadays, but I had to
93give it a try for old-time sake. Since the data is already there in a form of
94RSS feed, I could take this feed and parse it and create a WML version of the
95homepage.
96
97We will need:
98
99- Python3 + Pip
100- ImageMagick
101- feedparser and mako templating
102
103```sh
104# for fedora 35
105sudo dnf install ImageMagick python3-pip
106
107# tempalting engine for python
108pip install mako --user
109
110# for parsing rss feeds
111pip install feedparser --user
112```
113
114Project folder structure should look like the following.
115
116```
11712:43:53 m@khan wap → tree -L 1
118.
119├── generate.py
120└── template.wml
121
122```
123
124After that, I created a small template for the homepage.
125
126```html
127<?xml version="1.0"?>
128<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN" "http://www.wapforum.org/DTD/wml_1.2.xml">
129
130<wml>
131
132 <card title="Digg - What the Internet is talking about right now">
133
134 % for item in entries:
135 <p><img src="/images/${item.id}.jpg" width="175" height="95" alt="${item.title}" /></p>
136 <p><small>${item.kicker}</small></p>
137 <p><big><b>${item.title}</b></big></p>
138 <p>${item.description}</p>
139 % endfor
140
141 </card>
142
143</wml>
144```
145
146And the parser that parses RSS feed looks like this.
147
148```python
149import os
150import feedparser
151from mako.template import Template
152
153os.system('mkdir -p www/images')
154
155template = Template(filename='template.wml')
156
157feed = feedparser.parse('https://digg.com/rss/top.xml')
158
159entries = feed.entries[:15]
160
161for entry in entries:
162 print('Processing image with id {}'.format(entry.id))
163 os.system('wget -q -O www/images/{}.jpg "{}"'.format(entry.id, entry.links[1].href))
164 os.system('convert www/images/{}.jpg -type Grayscale -resize 175x -depth 3 -quality 30 www/images/{}.jpg'.format(entry.id, entry.id))
165
166html = template.render(entries = entries)
167
168with open('www/index.wml', 'w+') as fp:
169 fp.write(html)
170```
171
172This script will create a folder `www` and in the folder `www/images` for
173storing resized images.
174
175> Be sure you don't use SSL and use just normal HTTP for serving the content.
176> These old phones will have problems with TLS 1.3 etc.
177
178If you look at the python file, I convert all the images into tiny B&W images.
179They should be WBMP (Wireless BitMaP) but I choose JPEGs for this, and it seems
180to work properly.
181
182Because I currently don't have a phone old enough to test it on, I used an
183emulator. And it was really hard to find one. I found [WAP
184Proof](http://wap-proof.sharewarejunction.com/) on shareware junction, and it
185did the job well enough. I will try to find and actual device to test it on.
186
187<video src="/assets/wap/emulator.mp4" controls></video>
188
189If you are using Nginx to serve the contents, add a directive to the hosts file
190that will automatically server `index.wml` file.
191
192```nginx
193server {
194 index index.wml index.html index.htm index.nginx-debian.html;
195}
196```
197
198## Conclusion
199
200Well, this was pointless, but very fun! I hope you enjoyed it as much as I did.
201I will try to find an old phone to test it on. If you have any questions, feel
202free to ask in the comments.