mozilla / api.webmaker.org

Services for Webmaker
https://api.webmaker.org
17 stars 14 forks source link

Design Pages API #7

Closed cadecairos closed 9 years ago

cadecairos commented 9 years ago
thisandagain commented 9 years ago

I suggest we ditch "Remix a page to another project" as a requirement until we have a design that supports it. cc @xmatthewx

xmatthewx commented 9 years ago

We have remix Page as a new project. We don't have import page to an existing project, and I'm not sure that we should b/c of the UI it would require.

I'm fine with pushing this back in the roadmap if it's complicated. I do think it lowers the bar for participation and could be helpful for building momentum in the early days.

thisandagain commented 9 years ago

Gotcha. I'd like to punt as it muddies the metaphor quite a bit... let's keep it isolated to the project-level for now.

xmatthewx commented 9 years ago

Do you think we need to push this back beyond v1? :+1: Or, do you think it doesn't fit the platform?

thisandagain commented 9 years ago

Not needed for 1.0. Move to backlog.

xmatthewx commented 9 years ago

Cool. Moving to the backlog.

The web would be much less nimble if we could only point to and share sites, not pages. Our platform is more webby and more viable if we enable sharing and remixing of pages.

thisandagain commented 9 years ago

:+1: great point. Let's make sure to re-evaluate during the desktop design process.

thisandagain commented 9 years ago

API

POST /users/:user/projects/:project/pages – Create a new page
GET /users/:user/projects/:project/pages/:page – Get an existing page by ID
PUT /users/:user/projects/:project/pages/:page – Update an existing page by ID (auth, owner)
DEL /users/:user/projects/:project/pages/:page – Delete an existing page by ID (auth, owner)

Data Model

{
    "id": 1,
    "x": 0,
    "y": 0,
    "history": {
        "created_at": "2015-04-20T16:11:13.961Z",
        "updated_at": "2015-04-20T16:11:13.961Z",
        "deleted_at": null,
    },
    "styles": {
        "background-color": "#ff0000"
    }
}

SQL

CREATE TABLE pages (
    id bigserial PRIMARY KEY,
    created_at timestamp DEFAULT current_timestamp,
    updated_at timestamp DEFAULT current_timestamp,
    deleted_at timestamp,
    x integer DEFAULT 0 NOT NULL,
    y integer DEFAULT 0 NOT NULL,
    project_id bigint NOT NULL,
    styles json,
    UNIQUE(project_id, x, y)
);
cadecairos commented 9 years ago

Also needed:

GET /user/{users}/projects/{project}/pages - get all pages in a project