Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ number, date, relation, and so on.

## 2. Create a Subject

A Subject is one thing described with a Schema. Open any wiki page and pick **Create subject** from the page tools,
fill in the values, and save. The page's Main Subject renders automatically as an infobox, and the **Data** tab
lets you view and edit all its Subjects.
A Subject is one thing described with a Schema. Pick **Create subject** in the sidebar, or the **Create** button on
the Schema's own page (it names the Schema, so **Create Person** on `Schema:Person`), name the page the Subject will
live on, fill in the values, and save. The new page's Main Subject renders automatically as an infobox, and the
**Data** tab lets you view and edit all its Subjects. To attach a Subject to a page that already exists, open that
page and pick **Create subject here** from the page tools.

## 3. Render a View in wikitext

Expand Down
11 changes: 10 additions & 1 deletion extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@
"Schemas": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialSchemas",
"Layouts": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialLayouts",
"Mappings": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialMappings",
"GraphStores": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialGraphStores"
"GraphStores": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialGraphStores",
"CreateSubject": "ProfessionalWiki\\NeoWiki\\EntryPoints\\SpecialPages\\SpecialCreateSubject"
},

"Actions": {
Expand Down Expand Up @@ -597,7 +598,15 @@
"neowiki-subject-creator-schema-created",
"neowiki-subject-creator-creating-schema",
"neowiki-subject-creator-back",
"neowiki-subject-creator-page-field",
"neowiki-subject-creator-page-has-main-subject",
"neowiki-subject-creator-create-page-summary",
"neowiki-subject-creator-create-page-error",
"neowiki-subject-creator-page-taken",
"neowiki-subject-creator-page-read-error",
"neowiki-createsubject-button",
"neowiki-edit-schema",
"neowiki-schema-create-subject",
"neowiki-schema-delete",
"neowiki-schema-editor-summary-default",
"neowiki-schema-editor-success",
Expand Down
1 change: 1 addition & 0 deletions i18n/_Aliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
'Layouts' => [ 'Layouts' ],
'Mappings' => [ 'Mappings' ],
'GraphStores' => [ 'GraphStores' ],
'CreateSubject' => [ 'CreateSubject' ],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding NewSubject as alias seems useful. Can see people coming from Wikibase typing that

];
14 changes: 12 additions & 2 deletions i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

"specialpages-group-neowiki": "NeoWiki",
"neowiki-special-schemas": "Schemas",
"neowiki-special-createsubject": "Create subject",

"neowiki-property-type-text": "Text",
"neowiki-property-type-url": "URL",
Expand All @@ -39,7 +40,7 @@
"neowiki-neojson-description": "Editing neo slot of \"$1\"",

"neowiki-page-tools-label": "NeoWiki",
"neowiki-page-tools-create-subject": "Create subject",
"neowiki-page-tools-create-subject": "Create subject here",
"neowiki-page-tools-manage-subjects": "Manage subjects",
"neowiki-page-tools-view-subjects": "View subjects",
"neowiki-page-tools-edit-json": "View or edit JSON",
Expand Down Expand Up @@ -154,6 +155,13 @@
"neowiki-subject-creator-continue": "Continue",
"neowiki-subject-creator-schema-created": "Schema created successfully",
"neowiki-subject-creator-back": "Back",
"neowiki-subject-creator-page-field": "Page",
"neowiki-subject-creator-page-has-main-subject": "This page already has a Main Subject, $1. The new Subject will be added alongside it.",
"neowiki-subject-creator-create-page-summary": "Page created for a new Subject",
"neowiki-subject-creator-create-page-error": "The page \"$1\" could not be created.",
"neowiki-subject-creator-page-taken": "The page \"$1\" was created in the meantime. Pick it to add the Subject to it.",
"neowiki-subject-creator-page-read-error": "The page \"$1\" could not be read. Pick it again to retry.",
"neowiki-createsubject-button": "Create subject",

"neowiki-schema-display-property-name": "Property",
"neowiki-schema-display-property-type": "Type",
Expand Down Expand Up @@ -230,6 +238,8 @@
"neowiki-schemas-column-properties": "Properties",
"neowiki-schemas-empty": "No schemas have been created yet.",
"neowiki-schema-sidebar-all-schemas": "All schemas",
"neowiki-sidebar-create-subject": "Create subject",
"neowiki-schema-create-subject": "Create $1",

"neowiki-schema-delete": "Delete schema",

Expand Down Expand Up @@ -339,7 +349,7 @@
"neowiki-managesubjects-tab": "Data",
"neowiki-managesubjects-title": "Subjects on $1",
"neowiki-managesubjects-not-applicable": "Subject management is not available on this page.",
"neowiki-managesubjects-add-button": "Add subject",
"neowiki-managesubjects-add-button": "Create subject",
"neowiki-managesubjects-empty-title": "No subjects yet",
"neowiki-managesubjects-empty-description": "A subject describes one thing with structured data.",
"neowiki-managesubjects-no-main-title": "No main subject set",
Expand Down
12 changes: 11 additions & 1 deletion i18n/qqq.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"action-neowiki-admin": "{{doc-action|neowiki-admin}}",
"specialpages-group-neowiki": "Group heading for NeoWiki special pages on [[Special:SpecialPages]].",
"neowiki-special-schemas": "Title and description of the [[Special:Schemas]] page.",
"neowiki-special-createsubject": "Title and description of the [[Special:CreateSubject]] page, which creates a page together with its Main Subject. A subpage names the Schema to use, e.g. Special:CreateSubject/Person.",
"neowiki-schema-label": "Names a subject's schema. $1 is the schema name or a link to it. Also used as the accessible name of the schema badge, whose visible text is the bare name.",
"neowiki-cypher-raw-error-json-encode": "Error message shown when JSON encoding of query results fails.",

Expand All @@ -40,7 +41,7 @@
"neowiki-view-error-unknown-arg": "Error shown when {{#view}} receives an unrecognized named argument. $1 is the offending argument name.",

"neowiki-page-tools-label": "Heading for the NeoWiki section in the MediaWiki sidebar (shown as a group label in legacy skins and inside the page tools menu in modern Vector).",
"neowiki-page-tools-create-subject": "Label for the sidebar link that opens the 'create subject' dialog. The dialog creates a main subject if the page has none, or a child subject otherwise.",
"neowiki-page-tools-create-subject": "Label for the page tool that creates a Subject on the page being viewed, as opposed to [[Special:CreateSubject]], which creates the page too. The dialog it opens creates the page's Main Subject if it has none, or another Subject otherwise.",
"neowiki-page-tools-manage-subjects": "Label for the sidebar link to the Subject management page, shown to users who may edit. See neowiki-page-tools-view-subjects for the read-only variant.",
"neowiki-page-tools-view-subjects": "Read-only counterpart of neowiki-page-tools-manage-subjects: label for the sidebar link to the Subject management page, shown to users who lack edit permission.",
"neowiki-page-tools-edit-json": "Label for the sidebar link that navigates to Special:NeoJson for the current page. Only visible when development UIs are enabled.",
Expand All @@ -52,6 +53,13 @@
"neowiki-subject-creator-continue": "Label for the button that continues from schema creation to subject editing in the subject creator dialog.",
"neowiki-subject-creator-schema-created": "Success notification shown after creating a schema.",
"neowiki-subject-creator-back": "Aria label for the back button in the subject creator dialog, used to return to schema selection.",
"neowiki-subject-creator-page-field": "Label of the field in the 'create subject' dialog, when opened from [[Special:CreateSubject]], that picks the page the Subject will be stored on: an existing page or a title to create.",
"neowiki-subject-creator-page-has-main-subject": "Note in the 'create subject' dialog when the chosen page already has a Main Subject. Parameters:\n* $1 - the display name of that Main Subject",
"neowiki-subject-creator-create-page-summary": "Edit summary of the empty page created to hold a Subject, used when the user entered none.",
"neowiki-subject-creator-create-page-error": "Error shown at the page field of the 'create subject' dialog when the page could not be created. Parameters:\n* $1 - the page title",
"neowiki-subject-creator-page-taken": "Error shown at the page field of the 'create subject' dialog when the title to create was taken between choosing it and saving. Parameters:\n* $1 - the page title",
"neowiki-subject-creator-page-read-error": "Error shown at the page field of the 'create subject' dialog when the chosen page's Subjects could not be read, so the dialog cannot tell whether it has a Main Subject. Parameters:\n* $1 - the page title",
"neowiki-createsubject-button": "Label of the button on [[Special:CreateSubject]] that opens the 'create subject' dialog again after it was closed.",

"neowiki-schema-editor-summary-default": "Default edit summary used when updating a schema via the UI.",
"neowiki-schema-editor-success": "Success notification shown after updating a schema. $1 is the schema name.",
Expand Down Expand Up @@ -113,6 +121,8 @@
"neowiki-schemas-column-properties": "Column header for the number of property definitions in the schemas list table on [[Special:Schemas]].",
"neowiki-schemas-empty": "Message shown when no schemas exist yet on [[Special:Schemas]].",
"neowiki-schema-sidebar-all-schemas": "Label for the link in the NeoWiki section of the sidebar on Schema pages that navigates to [[Special:Schemas]].",
"neowiki-sidebar-create-subject": "Label for the link in the NeoWiki section of the sidebar that navigates to [[Special:CreateSubject]], where a Subject is created together with the page it lives on.",
"neowiki-schema-create-subject": "Label of the button on a Schema page that opens [[Special:CreateSubject]] with that Schema chosen. Parameters:\n* $1 - the Schema name",

"neowiki-schema-delete": "Aria label for the delete button on a Schema row in the schemas list.",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ export interface SubjectPermissionHints {
canDeleteSubject( subjectId: SubjectId ): Promise<boolean>;

canCreateMainSubject(): Promise<boolean>;

canCreateSubjectPage(): Promise<boolean>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<template>
<div class="ext-neowiki-create-subject-page">
<CdxButton
action="progressive"
weight="primary"
@click="subjectStore.openSubjectCreator()"
>
<CdxIcon :icon="cdxIconAdd" />
{{ $i18n( 'neowiki-createsubject-button' ).text() }}
</CdxButton>

<SubjectCreatorDialog
:page-has-main-subject="false"
:choose-page="true"
:initial-schema-name="props.schemaName"
/>
</div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
import { CdxButton, CdxIcon } from '@wikimedia/codex';
import { cdxIconAdd } from '@wikimedia/codex-icons';
import SubjectCreatorDialog from '@/components/SubjectCreator/SubjectCreatorDialog.vue';
import { useSubjectStore } from '@/stores/SubjectStore.ts';

const props = defineProps<{
schemaName?: string;
}>();

const subjectStore = useSubjectStore();

onMounted( () => {
subjectStore.openSubjectCreator();
} );
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<SchemaDisplayHeader
:schema="currentSchema"
:can-edit-schema="canEditSchema"
:can-create-subject="canCreateSubjectPage"
@edit="openEditor"
/>
</template>
Expand Down Expand Up @@ -72,7 +73,7 @@
</template>

<script setup lang="ts">
import { computed, shallowRef, watch } from 'vue';
import { computed, onMounted, shallowRef, watch } from 'vue';
import { Schema } from '@/domain/Schema.ts';
import { NeoWikiServices } from '@/NeoWikiServices.ts';
import { CdxTable, CdxInfoChip } from '@wikimedia/codex';
Expand All @@ -82,6 +83,7 @@ import SchemaDisplayHeader from './SchemaDisplayHeader.vue';
import SchemaEditorDialog from '@/components/SchemaEditor/SchemaEditorDialog.vue';
import { useSchemaStore } from '@/stores/SchemaStore.ts';
import { useSchemaPermissions } from '@/composables/useSchemaPermissions.ts';
import { useSubjectPermissions } from '@/composables/useSubjectPermissions.ts';

const props = defineProps( {
schema: {
Expand All @@ -93,6 +95,11 @@ const props = defineProps( {
const schemaStore = useSchemaStore();
const schemaRepo = NeoWikiServices.getSchemaRepository();
const { canEditSchema, checkEditPermission } = useSchemaPermissions();
const { canCreateSubjectPage, checkCreateSubjectPagePermission } = useSubjectPermissions();

onMounted( () => {
checkCreateSubjectPagePermission();
} );

const isEditorOpen = shallowRef( false );
const currentSchema = shallowRef<Schema>( props.schema );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
>
{{ schema.getDescription() }}
</div>
<a
v-if="canCreateSubject"
class="cdx-button cdx-button--fake-button cdx-button--fake-button--enabled cdx-button--action-progressive cdx-button--weight-primary ext-neowiki-schema-display-header__create-subject"
:href="createSubjectUrl"
>
<CdxIcon :icon="cdxIconAdd" />
{{ $i18n( 'neowiki-schema-create-subject', schema.getName() ).text() }}
</a>
</div>
<div class="ext-neowiki-schema-display-header__actions">
<CdxButton
Expand All @@ -25,21 +33,29 @@
</template>

<script setup lang="ts">
import { computed } from 'vue';
import { Schema } from '@/domain/Schema.ts';
import { CdxButton, CdxIcon } from '@wikimedia/codex';
import { cdxIconEdit } from '@wikimedia/codex-icons';
import { cdxIconAdd, cdxIconEdit } from '@wikimedia/codex-icons';

defineProps( {
const props = defineProps( {
schema: {
type: Schema,
required: true
},
canEditSchema: {
type: Boolean,
required: true
},
canCreateSubject: {
type: Boolean,
required: true
}
} );

const createSubjectUrl = computed( (): string =>
mw.util.getUrl( `Special:CreateSubject/${ props.schema.getName() }` ) );

const emit = defineEmits<{
edit: [];
}>();
Expand All @@ -65,5 +81,9 @@ const emit = defineEmits<{
&__description {
color: @color-subtle;
}

&__create-subject {
margin-top: @spacing-75;
}
}
</style>
Loading