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