Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/381913 )

Change subject: Chore: break apart page modules
......................................................................

Chore: break apart page modules

There are too many models in the page module. Break them apart.

Bug: T173317
Change-Id: I52dd459b517d767de8d457fcf0be679675725dfe
---
M src/common/components/page-summary/page-summary.tsx
M src/common/data-clients/page-summary-data-client.ts
M src/common/marshallers/page-unmarshaller.test.ts
M src/common/marshallers/page-unmarshaller.ts
D src/common/models/page.ts
A src/common/models/page/geolocation.ts
A src/common/models/page/image.ts
A src/common/models/page/summary.ts
A src/common/models/page/title.ts
M src/common/pages/summary.tsx
10 files changed, 64 insertions(+), 69 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/13/381913/1

diff --git a/src/common/components/page-summary/page-summary.tsx 
b/src/common/components/page-summary/page-summary.tsx
index abef9fc..cd13a9a 100644
--- a/src/common/components/page-summary/page-summary.tsx
+++ b/src/common/components/page-summary/page-summary.tsx
@@ -1,6 +1,6 @@
 import { h } from "preact";
 import "./page-summary.css";
-import { PageSummary as PageSummaryModel } from "../../models/page";
+import { PageSummary as PageSummaryModel } from "../../models/page/summary";
 import Content from "../content/content";
 
 export interface Props {
diff --git a/src/common/data-clients/page-summary-data-client.ts 
b/src/common/data-clients/page-summary-data-client.ts
index 3b32d00..bbee03c 100644
--- a/src/common/data-clients/page-summary-data-client.ts
+++ b/src/common/data-clients/page-summary-data-client.ts
@@ -1,5 +1,6 @@
 import * as fetch from "isomorphic-unfetch";
-import { PageSummary, PageTitlePath } from "../models/page";
+import { PageSummary } from "../models/page/summary";
+import { PageTitlePath } from "../models/page/title";
 import { RESTBase } from "../marshallers/restbase";
 import { unmarshalPageSummary } from "../marshallers/page-unmarshaller";
 import { PageRedirect } from "./page-redirect";
diff --git a/src/common/marshallers/page-unmarshaller.test.ts 
b/src/common/marshallers/page-unmarshaller.test.ts
index eada598..a2e488b 100644
--- a/src/common/marshallers/page-unmarshaller.test.ts
+++ b/src/common/marshallers/page-unmarshaller.test.ts
@@ -1,6 +1,6 @@
 import * as assert from "assert";
 import * as fetch from "node-fetch";
-import { PageSummary, pageSummaryReviver } from "../models/page";
+import { PageSummary, pageSummaryReviver } from "../models/page/summary";
 import { unmarshalPageSummary } from "./page-unmarshaller";
 import { RESTBase } from "./restbase";
 
diff --git a/src/common/marshallers/page-unmarshaller.ts 
b/src/common/marshallers/page-unmarshaller.ts
index 83e5a41..6122404 100644
--- a/src/common/marshallers/page-unmarshaller.ts
+++ b/src/common/marshallers/page-unmarshaller.ts
@@ -1,9 +1,6 @@
-import {
-  PageGeolocation,
-  PageImage,
-  PageSummary,
-  PageThumbnail
-} from "../models/page";
+import { PageImage, PageThumbnail } from "../models/page/image";
+import { PageGeolocation } from "../models/page/geolocation";
+import { PageSummary } from "../models/page/summary";
 import { IsomorphicHeaders } from "../types/isomorphic-unfetch-extras";
 import { JSONObject } from "../types/json";
 import { RESTBase } from "./restbase";
diff --git a/src/common/models/page.ts b/src/common/models/page.ts
deleted file mode 100644
index 334a7a3..0000000
--- a/src/common/models/page.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { RESTBase } from "../marshallers/restbase";
-
-/**
- * URL-decoded normalized wiki URL path. e.g.: Main_Page,
- * Bill_&_Ted's_Excellent_Adventure.
- */
-export type PageTitleID = string;
-
-/**
- * URL-encoded normalized wiki URL path. e.g.: Main_Page,
- * Bill_%26_Ted%27s_Excellent_Adventure.
- */
-export type PageTitlePath = string;
-
-/**
- * Plain text localized page title. e.g.:
- *   Possible: Banana, Main Page, Bill & Ted's Excellent Adventure, Talk:Pie.
- *   Impossible: Main_Page, Bill_%26_Ted%27s_Excellent_Adventure.
- */
-export type PageTitleText = string;
-
-export interface PageImage {
-  url: string;
-  width: number;
-  height: number;
-  landscape: boolean;
-}
-
-export interface PageThumbnail extends PageImage {
-  originalURL: string;
-}
-
-export interface PageGeolocation {
-  latitude: number;
-  longitude: number;
-}
-
-export interface PageSummary {
-  wikiLanguageCode: string;
-  localeDirection: string;
-  pageID: number;
-  lastModified: Date;
-  titleText: PageTitleText;
-  titleHTML: string;
-  descriptionText: string;
-  extractText: string;
-  extractHTML: string[];
-  thumbnail?: PageThumbnail;
-  image?: PageImage;
-  geolocation?: PageGeolocation;
-  etag: RESTBase.ETag;
-}
-
-export const pageSummaryReviver = (key: string, value: any): any =>
-  key === "lastModified" ? new Date(value) : value;
diff --git a/src/common/models/page/geolocation.ts 
b/src/common/models/page/geolocation.ts
new file mode 100644
index 0000000..f252817
--- /dev/null
+++ b/src/common/models/page/geolocation.ts
@@ -0,0 +1,4 @@
+export interface PageGeolocation {
+  latitude: number;
+  longitude: number;
+}
diff --git a/src/common/models/page/image.ts b/src/common/models/page/image.ts
new file mode 100644
index 0000000..fdf76b0
--- /dev/null
+++ b/src/common/models/page/image.ts
@@ -0,0 +1,10 @@
+export interface PageImage {
+  url: string;
+  width: number;
+  height: number;
+  landscape: boolean;
+}
+
+export interface PageThumbnail extends PageImage {
+  originalURL: string;
+}
diff --git a/src/common/models/page/summary.ts 
b/src/common/models/page/summary.ts
new file mode 100644
index 0000000..01f62f0
--- /dev/null
+++ b/src/common/models/page/summary.ts
@@ -0,0 +1,23 @@
+import { RESTBase } from "../../marshallers/restbase";
+import { PageGeolocation } from "./geolocation";
+import { PageImage, PageThumbnail } from "./image";
+import { PageTitleText } from "./title";
+
+export interface PageSummary {
+  wikiLanguageCode: string;
+  localeDirection: string;
+  pageID: number;
+  lastModified: Date;
+  titleText: PageTitleText;
+  titleHTML: string;
+  descriptionText: string;
+  extractText: string;
+  extractHTML: string[];
+  thumbnail?: PageThumbnail;
+  image?: PageImage;
+  geolocation?: PageGeolocation;
+  etag: RESTBase.ETag;
+}
+
+export const pageSummaryReviver = (key: string, value: any): any =>
+  key === "lastModified" ? new Date(value) : value;
diff --git a/src/common/models/page/title.ts b/src/common/models/page/title.ts
new file mode 100644
index 0000000..2993776
--- /dev/null
+++ b/src/common/models/page/title.ts
@@ -0,0 +1,18 @@
+/**
+ * URL-decoded normalized wiki URL path. e.g.: Main_Page,
+ * Bill_&_Ted's_Excellent_Adventure.
+ */
+export type PageTitleID = string;
+
+/**
+ * URL-encoded normalized wiki URL path. e.g.: Main_Page,
+ * Bill_%26_Ted%27s_Excellent_Adventure.
+ */
+export type PageTitlePath = string;
+
+/**
+ * Plain text localized page title. e.g.:
+ *   Possible: Banana, Main Page, Bill & Ted's Excellent Adventure, Talk:Pie.
+ *   Impossible: Main_Page, Bill_%26_Ted%27s_Excellent_Adventure.
+ */
+export type PageTitleText = string;
diff --git a/src/common/pages/summary.tsx b/src/common/pages/summary.tsx
index 23f3919..2641107 100644
--- a/src/common/pages/summary.tsx
+++ b/src/common/pages/summary.tsx
@@ -2,11 +2,8 @@
 import App from "../components/app/app";
 import Content from "../components/content/content";
 import { PageSummary } from "../components/page-summary/page-summary";
-import {
-  PageSummary as PageSummaryModel,
-  PageTitleID,
-  PageTitlePath
-} from "../models/page";
+import { PageSummary as PageSummaryModel } from "../models/page/summary";
+import { PageTitleID, PageTitlePath } from "../models/page/title";
 import Page from "../components/page/page";
 import { RouteParams } from "../routers/route";
 import { request } from "../data-clients/page-summary-data-client";

-- 
To view, visit https://gerrit.wikimedia.org/r/381913
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I52dd459b517d767de8d457fcf0be679675725dfe
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to