|
6 | 6 | "source": [
|
7 | 7 | "# Leaflet cluster map of talk locations\n",
|
8 | 8 | "\n",
|
9 |
| - "Run this from the _talks/ directory, which contains .md files of all your talks. This scrapes the location YAML field from each .md file, geolocates it with geopy/Nominatim, and uses the getorg library to output data, HTML, and Javascript for a standalone cluster map." |
| 9 | + "Assuming you are working in a Linux or Windows Subsystem for Linux environment, you may need to install some dependencies. Assuming a clean installation, the following will be needed:\n", |
| 10 | + "\n", |
| 11 | + "```bash\n", |
| 12 | + "sudo apt install jupyter\n", |
| 13 | + "sudo apt install python3-pip\n", |
| 14 | + "pip install getorg --upgrade\n", |
| 15 | + "```\n", |
| 16 | + "\n", |
| 17 | + "After which you can run this from the `_talks/` directory, via:\n", |
| 18 | + "\n", |
| 19 | + "```bash\n", |
| 20 | + " jupyter nbconvert --to notebook --execute talkmap.ipynb --output talkmap_out.ipynb\n", |
| 21 | + "```\n", |
| 22 | + " \n", |
| 23 | + "The `_talks/` directory contains `.md` files of all your talks. This scrapes the location YAML field from each `.md` file, geolocates it with `geopy/Nominatim`, and uses the `getorg` library to output data, HTML, and Javascript for a standalone cluster map." |
10 | 24 | ]
|
11 | 25 | },
|
12 | 26 | {
|
|
15 | 29 | "metadata": {
|
16 | 30 | "collapsed": false,
|
17 | 31 | "execution": {
|
18 |
| - "iopub.execute_input": "2025-02-22T01:09:40.748788Z", |
19 |
| - "iopub.status.busy": "2025-02-22T01:09:40.748590Z", |
20 |
| - "iopub.status.idle": "2025-02-22T01:09:41.820985Z", |
21 |
| - "shell.execute_reply": "2025-02-22T01:09:41.820264Z" |
| 32 | + "iopub.execute_input": "2025-02-22T01:30:05.703774Z", |
| 33 | + "iopub.status.busy": "2025-02-22T01:30:05.703517Z", |
| 34 | + "iopub.status.idle": "2025-02-22T01:30:06.843336Z", |
| 35 | + "shell.execute_reply": "2025-02-22T01:30:06.842591Z" |
22 | 36 | }
|
23 | 37 | },
|
24 | 38 | "outputs": [
|
|
43 | 57 | "Requirement already satisfied: typing-extensions>=4.0.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (4.12.2)\r\n",
|
44 | 58 | "Requirement already satisfied: urllib3>=1.26.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (2.3.0)\r\n",
|
45 | 59 | "Requirement already satisfied: Deprecated in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pygithub->getorg) (1.2.18)\r\n",
|
46 |
| - "Requirement already satisfied: six>=1.7.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from retrying->getorg) (1.17.0)\r\n", |
| 60 | + "Requirement already satisfied: six>=1.7.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from retrying->getorg) (1.17.0)\r\n" |
| 61 | + ] |
| 62 | + }, |
| 63 | + { |
| 64 | + "name": "stdout", |
| 65 | + "output_type": "stream", |
| 66 | + "text": [ |
47 | 67 | "Requirement already satisfied: cryptography>=3.4.0 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pyjwt[crypto]>=2.4.0->pygithub->getorg) (44.0.1)\r\n",
|
48 | 68 | "Requirement already satisfied: cffi>=1.4.1 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from pynacl>=1.4.0->pygithub->getorg) (1.17.1)\r\n",
|
49 | 69 | "Requirement already satisfied: charset-normalizer<4,>=2 in /opt/hostedtoolcache/Python/3.9.21/x64/lib/python3.9/site-packages (from requests>=2.14.0->pygithub->getorg) (3.4.1)\r\n",
|
|
66 | 86 | }
|
67 | 87 | ],
|
68 | 88 | "source": [
|
| 89 | + "# Start by installing the dependencies\n", |
69 | 90 | "!pip install getorg --upgrade\n",
|
70 | 91 | "import glob\n",
|
71 | 92 | "import getorg\n",
|
|
78 | 99 | "metadata": {
|
79 | 100 | "collapsed": false,
|
80 | 101 | "execution": {
|
81 |
| - "iopub.execute_input": "2025-02-22T01:09:41.823539Z", |
82 |
| - "iopub.status.busy": "2025-02-22T01:09:41.823058Z", |
83 |
| - "iopub.status.idle": "2025-02-22T01:09:41.826460Z", |
84 |
| - "shell.execute_reply": "2025-02-22T01:09:41.825940Z" |
| 102 | + "iopub.execute_input": "2025-02-22T01:30:06.845946Z", |
| 103 | + "iopub.status.busy": "2025-02-22T01:30:06.845467Z", |
| 104 | + "iopub.status.idle": "2025-02-22T01:30:06.849121Z", |
| 105 | + "shell.execute_reply": "2025-02-22T01:30:06.848477Z" |
85 | 106 | }
|
86 | 107 | },
|
87 | 108 | "outputs": [],
|
88 | 109 | "source": [
|
| 110 | + "# Collect the Markdown files\n", |
89 | 111 | "g = glob.glob(\"*.md\")"
|
90 | 112 | ]
|
91 | 113 | },
|
|
95 | 117 | "metadata": {
|
96 | 118 | "collapsed": true,
|
97 | 119 | "execution": {
|
98 |
| - "iopub.execute_input": "2025-02-22T01:09:41.828648Z", |
99 |
| - "iopub.status.busy": "2025-02-22T01:09:41.828276Z", |
100 |
| - "iopub.status.idle": "2025-02-22T01:09:41.853054Z", |
101 |
| - "shell.execute_reply": "2025-02-22T01:09:41.852554Z" |
| 120 | + "iopub.execute_input": "2025-02-22T01:30:06.851364Z", |
| 121 | + "iopub.status.busy": "2025-02-22T01:30:06.850962Z", |
| 122 | + "iopub.status.idle": "2025-02-22T01:30:06.876444Z", |
| 123 | + "shell.execute_reply": "2025-02-22T01:30:06.875850Z" |
102 | 124 | }
|
103 | 125 | },
|
104 | 126 | "outputs": [],
|
105 | 127 | "source": [
|
| 128 | + "# Prepare to geolocate\n", |
106 | 129 | "geocoder = Nominatim(user_agent=\"academicpages.github.io\")\n",
|
107 | 130 | "location_dict = {}\n",
|
108 | 131 | "location = \"\"\n",
|
|
116 | 139 | "metadata": {
|
117 | 140 | "collapsed": false,
|
118 | 141 | "execution": {
|
119 |
| - "iopub.execute_input": "2025-02-22T01:09:41.855227Z", |
120 |
| - "iopub.status.busy": "2025-02-22T01:09:41.854845Z", |
121 |
| - "iopub.status.idle": "2025-02-22T01:09:44.188915Z", |
122 |
| - "shell.execute_reply": "2025-02-22T01:09:44.188226Z" |
| 142 | + "iopub.execute_input": "2025-02-22T01:30:06.878925Z", |
| 143 | + "iopub.status.busy": "2025-02-22T01:30:06.878494Z", |
| 144 | + "iopub.status.idle": "2025-02-22T01:30:09.224074Z", |
| 145 | + "shell.execute_reply": "2025-02-22T01:30:09.223402Z" |
123 | 146 | }
|
124 | 147 | },
|
125 | 148 | "outputs": [
|
|
141 | 164 | }
|
142 | 165 | ],
|
143 | 166 | "source": [
|
144 |
| - "\n", |
| 167 | + "# Perform geolocation\n", |
145 | 168 | "for file in g:\n",
|
146 | 169 | " with open(file, 'r') as f:\n",
|
147 | 170 | " lines = f.read()\n",
|
|
162 | 185 | "metadata": {
|
163 | 186 | "collapsed": false,
|
164 | 187 | "execution": {
|
165 |
| - "iopub.execute_input": "2025-02-22T01:09:44.191211Z", |
166 |
| - "iopub.status.busy": "2025-02-22T01:09:44.190804Z", |
167 |
| - "iopub.status.idle": "2025-02-22T01:09:44.198598Z", |
168 |
| - "shell.execute_reply": "2025-02-22T01:09:44.197939Z" |
| 188 | + "iopub.execute_input": "2025-02-22T01:30:09.226429Z", |
| 189 | + "iopub.status.busy": "2025-02-22T01:30:09.225951Z", |
| 190 | + "iopub.status.idle": "2025-02-22T01:30:09.233806Z", |
| 191 | + "shell.execute_reply": "2025-02-22T01:30:09.233240Z" |
169 | 192 | }
|
170 | 193 | },
|
171 | 194 | "outputs": [
|
|
181 | 204 | }
|
182 | 205 | ],
|
183 | 206 | "source": [
|
| 207 | + "# Save the map\n", |
184 | 208 | "m = getorg.orgmap.create_map_obj()\n",
|
185 | 209 | "getorg.orgmap.output_html_cluster_map(location_dict, folder_name=\"../talkmap\", hashed_usernames=False)"
|
186 | 210 | ]
|
|
0 commit comments