gtfs-to-html 2.6.3 → 2.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [2.6.5] - 2024-05-11
9
+
10
+ ### Updated
11
+ - Timetable trip notes on vertical
12
+ - Use route_text_color in timetable continuations
13
+ - Dependency updates
14
+
15
+ ### Fixed
16
+ - Handle trips with nostoptimes in overview
17
+
18
+ ## [2.6.4] - 2024-04-30
19
+
20
+ ### Updated
21
+ - Upated Mapbox GL
22
+
23
+ ### Added
24
+ - `startDate` and `endDate` config.json parameters
25
+
8
26
  ## [2.6.3] - 2024-04-22
9
27
 
10
28
  ### Updated
package/lib/utils.js CHANGED
@@ -542,7 +542,27 @@ const convertRouteToTimetablePage = (
542
542
  const convertRoutesToTimetablePages = (config) => {
543
543
  const db = openDb(config);
544
544
  const routes = getRoutes();
545
- const calendars = getCalendars();
545
+
546
+ let whereClause = '';
547
+ const whereClauses = [];
548
+
549
+ if (config.endDate) {
550
+ whereClauses.push(
551
+ `start_date <= ${sqlString.escape(toGTFSDate(moment(config.endDate)))}`,
552
+ );
553
+ }
554
+
555
+ if (config.startDate) {
556
+ whereClauses.push(
557
+ `end_date >= ${sqlString.escape(toGTFSDate(moment(config.startDate)))}`,
558
+ );
559
+ }
560
+
561
+ if (whereClauses.length > 0) {
562
+ whereClause = `WHERE ${whereClauses.join(' AND ')}`;
563
+ }
564
+
565
+ const calendars = db.prepare(`SELECT * FROM calendar ${whereClause}`).all();
546
566
 
547
567
  // Find all calendar dates with service_ids not present in `calendar.txt`.
548
568
  const serviceIds = calendars.map((calendar) => calendar.service_id);
@@ -917,7 +937,7 @@ const getTripsWithSameBlock = (trip, timetable) => {
917
937
  * departs from the same stop and is a different route.
918
938
  */
919
939
  const addTripContinuation = (trip, timetable) => {
920
- if (!trip.block_id) {
940
+ if (!trip.block_id || trip.stoptimes.length === 0) {
921
941
  return;
922
942
  }
923
943
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs-to-html",
3
- "version": "2.6.3",
3
+ "version": "2.6.5",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -51,7 +51,7 @@
51
51
  "morgan": "^1.10.0",
52
52
  "pretty-error": "^4.0.0",
53
53
  "pug": "^3.0.2",
54
- "puppeteer": "^22.6.5",
54
+ "puppeteer": "^22.8.0",
55
55
  "sanitize-filename": "^1.6.3",
56
56
  "sqlstring": "^2.3.3",
57
57
  "timer-machine": "^1.1.0",
@@ -6,9 +6,9 @@ block extraHeader
6
6
  if config.showMap
7
7
  script(src="https://unpkg.com/jquery@3.7.1/dist/jquery.min.js" crossorigin="anonymous")
8
8
  script(src="https://unpkg.com/lodash@4.17.21/lodash.min.js" crossorigin="anonymous")
9
- script(src="https://api.mapbox.com/mapbox-gl-js/v3.1.0/mapbox-gl.js")
9
+ script(src="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js")
10
10
  script.
11
11
  mapboxgl.accessToken = '#{config.mapboxAccessToken}';
12
12
  script(src=`${config.assetPath}js/system-map.js`)
13
13
 
14
- link(href="https://api.mapbox.com/mapbox-gl-js/v3.1.0/mapbox-gl.css" rel="stylesheet")
14
+ link(href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css" rel="stylesheet")
@@ -1,6 +1,6 @@
1
1
  if trip.continues_as_route && trip.continues_as_route.route.route_color
2
2
  - var tdStyle = `background: #${trip.continues_as_route.route.route_color};`
3
- - var aStyle = 'color: #ffffff;'
3
+ - var aStyle = `color: #${trip.continues_as_route.route.route_text_color || 'ffffff'};`
4
4
  else
5
5
  - var tdStyle = ''
6
6
  - var aStyle = ''
@@ -1,6 +1,6 @@
1
1
  if trip.continues_from_route && trip.continues_from_route.route.route_color
2
2
  - var tdStyle = `background: #${trip.continues_from_route.route.route_color};`
3
- - var aStyle = 'color: #ffffff;'
3
+ - var aStyle = `color: #${trip.continues_from_route.route.route_text_color || 'ffffff'};`
4
4
  else
5
5
  - var tdStyle = ''
6
6
  - var aStyle = ''
@@ -7,6 +7,7 @@
7
7
  - return memo;
8
8
  - }, 0);
9
9
  - }
10
+ - var timetableHasTripNotes = timetable.orderedTrips.flatMap(trip => getNotesForTrip(timetable.notes, trip)).length > 0;
10
11
  .table-container
11
12
  table(summary= getTimetableSummary(timetable) data-orientation="vertical")
12
13
  caption.sr-only= `${timetable.timetable_label} | ${timetable.dayList}`
@@ -15,6 +16,8 @@
15
16
  col(id=`stop_id_${formatHtmlId(stop.stop_id)}` class=`stop-${idx}` data-stop-id=`${stop.stop_id}` data-is-timepoint=`${stop.is_timepoint}`)
16
17
  thead
17
18
  tr
19
+ if timetableHasTripNotes
20
+ th
18
21
  if timetable.has_continues_from_route
19
22
  th.stop-header.continues-from Continues from route
20
23
 
@@ -33,6 +36,8 @@
33
36
  tbody
34
37
  if timetable.frequencies && !timetable.frequencyExactTimes
35
38
  tr.trip-row
39
+ if timetableHasTripNotes
40
+ td
36
41
  if timetable.has_continues_from_route
37
42
  td
38
43
 
@@ -42,6 +47,10 @@
42
47
  td
43
48
  each trip, idx in timetable.orderedTrips
44
49
  tr.trip-row(id=`trip_id_${formatHtmlId(trip.trip_id)}`)
50
+ if timetableHasTripNotes
51
+ td.trip-notes
52
+ each note in getNotesForTrip(timetable.notes, trip)
53
+ include timetable_note_symbol.pug
45
54
  if timetable.has_continues_from_route
46
55
  include timetable_continuation_from.pug
47
56
 
@@ -9,10 +9,10 @@ block extraHeader
9
9
  script(src=`${config.assetPath}js/timetable-menu.js`)
10
10
 
11
11
  if config.showMap
12
- script(src="https://api.mapbox.com/mapbox-gl-js/v3.1.0/mapbox-gl.js")
12
+ script(src="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.js")
13
13
  script.
14
14
  mapboxgl.accessToken = '#{config.mapboxAccessToken}';
15
15
  script(src=`${config.assetPath}js/timetable-map.js`)
16
16
 
17
- link(href="https://api.mapbox.com/mapbox-gl-js/v3.1.0/mapbox-gl.css" rel="stylesheet")
17
+ link(href="https://api.mapbox.com/mapbox-gl-js/v3.3.0/mapbox-gl.css" rel="stylesheet")
18
18
 
@@ -25,6 +25,7 @@ All files starting with `config*.json` are .gitignored - so you can create multi
25
25
  | [`debug`](#debug) | boolean | Enable logging of SQL queries and other info. |
26
26
  | [`defaultOrientation`](#defaultorientation) | string | Specify timetable orientation, when not specified in `timetables.txt`. |
27
27
  | [`effectiveDate`](#effectivedate) | string | A date to print at the top of the timetable. |
28
+ | [`endDate`](#enddate) | string | A date in ISO 8601 format to use to control which calendars are used for the timetables. |
28
29
  | [`interpolatedStopSymbol`](#interpolatedstopsymbol) | string | The symbol used to indicate that a timepoint isn't fixed, but just interpolated. |
29
30
  | [`interpolatedStopText`](#interpolatedstoptext) | string | The text used to describe a timepoint isn't fixed, but just interpolated. |
30
31
  | [`linkStopUrls`](#linkStopurls) | boolean | Whether or not to hyperlink timetable stop names to the `stop_url` defined in `stops.txt`. |
@@ -56,6 +57,7 @@ All files starting with `config*.json` are .gitignored - so you can create multi
56
57
  | [`skipImport`](#skipimport) | boolean | Whether or not to skip importing GTFS data into SQLite. |
57
58
  | [`sortingAlgorithm`](#sortingalgorithm) | string | Defines the trip-sorting algorithm. |
58
59
  | [`sqlitePath`](#sqlitepath) | string | A path to an SQLite database. Optional, defaults to using an in-memory database. |
60
+ | [`startDate`](#startdate) | string | A date in ISO 8601 format to use to control which calendars are used for the timetables. |
59
61
  | [`templatePath`](#templatepath) | string | Path to custom pug template for rendering timetable. |
60
62
  | [`timeFormat`](#timeformat) | string | A string defining time format in moment.js style. |
61
63
  | [`useParentStation`](#useparentstation) | boolean | Whether or not to use a stop's `parent_station`. |
@@ -231,6 +233,16 @@ API along with your API token.
231
233
  "effectiveDate": "July 8, 2015"
232
234
  ```
233
235
 
236
+ ### endDate
237
+
238
+ \{String\} A date in ISO 8601 format to use to control which calendars are used for the timetables. Can be used with [startDate](#startdate) configuration options. Can be formatted as `YYYY-MM-DD` or `YYYYMMDD`.
239
+
240
+ Optional, defaults to using all available calendars if not defined. Overridden by `start_date` and `end_date` defined in `timetables.txt`.
241
+
242
+ ```json
243
+ "endDate": "2024-04-01"
244
+ ```
245
+
234
246
  ### interpolatedStopSymbol
235
247
 
236
248
  \{String\} The symbol used to indicate that a timepoint isn't fixed, but just interpolated. Defaults to `•`. To avoid having this symbol used in timetables, set it to `null`.
@@ -505,6 +517,16 @@ The default trip-sorting algorithm is `common`.
505
517
  "sqlitePath": "/tmp/gtfs"
506
518
  ```
507
519
 
520
+ ### startDate
521
+
522
+ \{String\} A date in ISO 8601 format to use to control which calendars are used for the timetables. Can be used with [endDate](#enddate) configuration options. Can be formatted as `YYYY-MM-DD` or `YYYYMMDD`.
523
+
524
+ Optional, defaults to using all available calendars if not defined. Overridden by `start_date` and `end_date` defined in `timetables.txt`.
525
+
526
+ ```json
527
+ "startDate": "2024-03-01"
528
+ ```
529
+
508
530
  ### templatePath
509
531
 
510
532
  \{String\} Path to a folder containing (pug)[https://pugjs.org/] template for rendering timetables. This is optional. Defaults to using the templates provided in `views/default`. All files within the `/views/custom` folder will be .gitignored, so you can copy the `views/default` folder to `views/custom/myagency` and make any modifications needed. Any custom views folder should contain pug templates called `timetablepage.pug`, `timetablepage_full.pug`, `overview.pug`, and `overview_full.pug`.
@@ -19,7 +19,7 @@ gtfs-to-html
19
19
 
20
20
  `configPath`
21
21
 
22
- Allows specifying a path to a configuration json file. By default, `gtfs-to-html` will look for a `config.json` file in the directory it is being run from.
22
+ Allows specifying a path to a configuration json file. By default, `gtfs-to-html` will look for a `config.json` file in the directory it is being run from. [See all configuration options](https://gtfstohtml.com/docs/configuration)
23
23
  ```bash
24
24
  gtfs-to-html --configPath /path/to/your/custom-config.json
25
25
  ```
@@ -29,6 +29,10 @@ Skips importing GTFS into SQLite. Useful if you are rerunning with an unchanged
29
29
  ```bash
30
30
  gtfs-to-html --skipImport
31
31
  ```
32
+ ### Customizing the output
33
+
34
+ You can create your own template to completely customize the HTML output using [custom templates](https://gtfstohtml.com/docs/custom-templates).
35
+
32
36
  ### Processing very large GTFS files.
33
37
 
34
38
  By default, node has a memory limit of 512 MB or 1 GB. If you have a very large GTFS file and want to use the option `showOnlyTimepoint` = `false` you may need to allocate more memory. Use the `max-old-space-size` option. For example to allocate 4 GB:
@@ -120,27 +124,13 @@ Once running, you can view the HTML in your browser at [localhost:3000](http://l
120
124
 
121
125
  ## Usage as a hosted web app
122
126
 
123
- A [hosted version of GTFS-to-HTML as a service](https://run.gtfstohtml.com) allows you to use it entirely within your browser - no downloads or command line necessary.
127
+ A [hosted version of GTFS-to-HTML as a service](https://run.gtfstohtml.com) allows you to use it entirely within your browser - no downloads or command line necessary. Currently, it is limited to relatively small GTFS files and doesn't offer support for [Custom Templates](/docs/custom-templates).
124
128
 
125
129
  It provides:
126
130
 
127
131
  - a web-based interface for finding GTFS feeds or ability to enter your own URL
128
132
  - support for adding [custom configuration](/docs/configuration) as JSON
129
- - creation of HTML timetables as a downloadable .zip file
133
+ - creation of HTML or PDF timetables as a downloadable .zip file
130
134
  - a preview of all timetables generated directly in your browser
131
135
 
132
- [run.gtfstohtml.com](https://run.gtfstohtml.com)
133
-
134
- Currently, it is limited to relatively small GTFS files and doesn't offer support for [Custom Templates](/docs/custom-templates).
135
-
136
- ## Troubleshooting
137
-
138
- ### SQLite3 unable to be installed with `Failed to exec install script`
139
-
140
- For an error like:
141
- `lifecycle sqlite3@5.0.0~install: Failed to exec install script`
142
-
143
- Try installing `gtfs-to-html` using the following flags:
144
- ```bash
145
- npm install --unsafe-perm --allow-root -g
146
- ```
136
+ [run.gtfstohtml.com](https://run.gtfstohtml.com)