gtfs-to-html 2.6.3 → 2.6.4

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,14 @@ 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.4] - 2024-04-30
9
+
10
+ ### Updated
11
+ - Upated Mapbox GL
12
+
13
+ ### Added
14
+ - `startDate` and `endDate` config.json parameters
15
+
8
16
  ## [2.6.3] - 2024-04-22
9
17
 
10
18
  ### 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);
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.4",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -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")
@@ -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)