mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	Send published/modified date when saving whole page
This commit is contained in:
		
							parent
							
								
									71be9515b9
								
							
						
					
					
						commit
						1434773572
					
				
							
								
								
									
										33
									
								
								content.js
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								content.js
									
									
									
									
									
								
							@ -42,6 +42,27 @@ function getReadableDocument() {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function getDocumentDates() {
 | 
				
			||||||
 | 
						var dates = {
 | 
				
			||||||
 | 
							publishedDate: null,
 | 
				
			||||||
 | 
							modifiedDate: null,  
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						const articlePublishedTime = document.querySelector("meta[property='article:published_time']");
 | 
				
			||||||
 | 
						if (articlePublishedTime && articlePublishedTime.getAttribute('content')) {
 | 
				
			||||||
 | 
							dates.publishedDate = new Date(articlePublishedTime.getAttribute('content'));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						const articleModifiedTime = document.querySelector("meta[property='article:modified_time']");
 | 
				
			||||||
 | 
						if (articleModifiedTime && articleModifiedTime.getAttribute('content')) {
 | 
				
			||||||
 | 
							dates.modifiedDate = new Date(articleModifiedTime.getAttribute('content'));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						// TODO: if we didn't get dates from meta, then try to get them from JSON-LD
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return dates;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function getRectangleArea() {
 | 
					function getRectangleArea() {
 | 
				
			||||||
	return new Promise((resolve, reject) => {
 | 
						return new Promise((resolve, reject) => {
 | 
				
			||||||
		const overlay = document.createElement('div');
 | 
							const overlay = document.createElement('div');
 | 
				
			||||||
@ -294,12 +315,22 @@ async function prepareMessageResponse(message) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		const images = getImages(body);
 | 
							const images = getImages(body);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        var labels = {};
 | 
				
			||||||
 | 
							const dates = getDocumentDates();
 | 
				
			||||||
 | 
							if (dates.publishedDate) {
 | 
				
			||||||
 | 
								labels['publishedDate'] = dates.publishedDate.toISOString().substring(0, 10);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (dates.modifiedDate) {
 | 
				
			||||||
 | 
								labels['modifiedDate'] = dates.publishedDate.toISOString().substring(0, 10);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return {
 | 
							return {
 | 
				
			||||||
			title: title,
 | 
								title: title,
 | 
				
			||||||
			content: body.innerHTML,
 | 
								content: body.innerHTML,
 | 
				
			||||||
			images: images,
 | 
								images: images,
 | 
				
			||||||
			pageUrl: getPageLocationOrigin() + location.pathname + location.search,
 | 
								pageUrl: getPageLocationOrigin() + location.pathname + location.search,
 | 
				
			||||||
			clipType: 'page'
 | 
								clipType: 'page',
 | 
				
			||||||
 | 
								labels: labels
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	else {
 | 
						else {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user