mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-21 22:09:36 +02:00
Wikipedia description fetch
This commit is contained in:
parent
cfe14b3708
commit
add2e2bafa
2 changed files with 212 additions and 194 deletions
|
@ -23,6 +23,8 @@
|
||||||
export let startDate: string | null = null;
|
export let startDate: string | null = null;
|
||||||
export let endDate: string | null = null;
|
export let endDate: string | null = null;
|
||||||
|
|
||||||
|
let wikiError: string = '';
|
||||||
|
|
||||||
let noPlaces: boolean = false;
|
let noPlaces: boolean = false;
|
||||||
|
|
||||||
export let adventureToEdit: Adventure | null = null;
|
export let adventureToEdit: Adventure | null = null;
|
||||||
|
@ -57,7 +59,8 @@
|
||||||
lngLat: { lng: adventure.longitude, lat: adventure.latitude },
|
lngLat: { lng: adventure.longitude, lat: adventure.latitude },
|
||||||
location: adventure.location || '',
|
location: adventure.location || '',
|
||||||
name: adventure.name,
|
name: adventure.name,
|
||||||
activity_type: ''
|
activity_type: '',
|
||||||
|
lng: 0
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -210,7 +213,8 @@
|
||||||
lngLat: { lng: longitude, lat: latitude },
|
lngLat: { lng: longitude, lat: latitude },
|
||||||
location: data[0]?.display_name || '',
|
location: data[0]?.display_name || '',
|
||||||
name: data[0]?.name || '',
|
name: data[0]?.name || '',
|
||||||
activity_type: data[0]?.type || ''
|
activity_type: data[0]?.type || '',
|
||||||
|
lng: 0
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -240,17 +244,28 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// async function generateDesc() {
|
async function generateDesc() {
|
||||||
// let res = await fetch(`/api/generate/desc/?name=${adventureToEdit.name}`);
|
let res = await fetch(`/api/generate/desc/?name=${adventure.name}`);
|
||||||
// let data = await res.json();
|
let data = await res.json();
|
||||||
// if (data.extract) {
|
if (data.extract?.length > 0) {
|
||||||
// adventureToEdit.description = data.extract;
|
adventure.description = data.extract;
|
||||||
// }
|
} else {
|
||||||
// }
|
wikiError = 'No description found';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function addMarker(e: CustomEvent<any>) {
|
function addMarker(e: CustomEvent<any>) {
|
||||||
markers = [];
|
markers = [];
|
||||||
markers = [...markers, { lngLat: e.detail.lngLat, name: '', location: '', activity_type: '' }];
|
markers = [
|
||||||
|
...markers,
|
||||||
|
{
|
||||||
|
lngLat: e.detail.lngLat,
|
||||||
|
name: '',
|
||||||
|
location: '',
|
||||||
|
activity_type: '',
|
||||||
|
lng: 0
|
||||||
|
}
|
||||||
|
];
|
||||||
console.log(markers);
|
console.log(markers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,6 +408,11 @@
|
||||||
bind:value={adventure.description}
|
bind:value={adventure.description}
|
||||||
class="textarea textarea-bordered w-full h-32"
|
class="textarea textarea-bordered w-full h-32"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
<div class="mt-2">
|
||||||
|
<button type="button" class="btn btn-neutral" on:click={generateDesc}
|
||||||
|
>Generate Description</button
|
||||||
|
>
|
||||||
|
<p class="text-red-500">{wikiError}</p>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="activity_types">Activity Types</label><br />
|
<label for="activity_types">Activity Types</label><br />
|
||||||
|
@ -530,7 +550,8 @@
|
||||||
lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
|
lngLat: { lng: Number(place.lon), lat: Number(place.lat) },
|
||||||
location: place.display_name,
|
location: place.display_name,
|
||||||
name: place.name,
|
name: place.name,
|
||||||
activity_type: place.type
|
activity_type: place.type,
|
||||||
|
lng: 0
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}}
|
}}
|
||||||
|
@ -586,6 +607,7 @@ it would also work to just use on:click on the MapLibre component itself. -->
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
|
@ -22,9 +22,6 @@
|
||||||
includeCollections: true
|
includeCollections: true
|
||||||
};
|
};
|
||||||
|
|
||||||
let isShowingCreateModal: boolean = false;
|
|
||||||
let newType: string = '';
|
|
||||||
|
|
||||||
let resultsPerPage: number = 25;
|
let resultsPerPage: number = 25;
|
||||||
|
|
||||||
let count = data.props.count || 0;
|
let count = data.props.count || 0;
|
||||||
|
@ -152,7 +149,6 @@
|
||||||
class="btn btn-primary"
|
class="btn btn-primary"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
isAdventureModalOpen = true;
|
isAdventureModalOpen = true;
|
||||||
newType = 'visited';
|
|
||||||
adventureToEdit = null;
|
adventureToEdit = null;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue