Add Linker and Optimizer modules with API integration and frontend components
- Added Linker and Optimizer apps to `INSTALLED_APPS` in `settings.py`. - Configured API endpoints for Linker and Optimizer in `urls.py`. - Implemented `OptimizeContentFunction` for content optimization in the AI module. - Created prompts for content optimization and site structure generation. - Updated `OptimizerService` to utilize the new AI function for content optimization. - Developed frontend components including dashboards and content lists for Linker and Optimizer. - Integrated new routes and sidebar navigation for Linker and Optimizer in the frontend. - Enhanced content management with source and sync status filters in the Writer module. - Comprehensive test coverage added for new features and components.
This commit is contained in:
32
frontend/src/api/linker.api.ts
Normal file
32
frontend/src/api/linker.api.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { fetchAPI } from '../services/api';
|
||||
|
||||
/**
|
||||
* Linker API Client
|
||||
* Functions for internal linking operations
|
||||
*/
|
||||
export const linkerApi = {
|
||||
/**
|
||||
* Process a single content item for internal linking
|
||||
* @param contentId - Content ID to process
|
||||
* @returns Link result with links added
|
||||
*/
|
||||
process: async (contentId: number) => {
|
||||
return await fetchAPI('/v1/linker/process/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ content_id: contentId }),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Batch process multiple content items for internal linking
|
||||
* @param contentIds - Array of content IDs to process
|
||||
* @returns Array of link results
|
||||
*/
|
||||
batchProcess: async (contentIds: number[]) => {
|
||||
return await fetchAPI('/v1/linker/batch_process/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ content_ids: contentIds }),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
86
frontend/src/api/optimizer.api.ts
Normal file
86
frontend/src/api/optimizer.api.ts
Normal file
@@ -0,0 +1,86 @@
|
||||
import { fetchAPI } from '../services/api';
|
||||
|
||||
/**
|
||||
* Optimizer API Client
|
||||
* Functions for content optimization operations
|
||||
*/
|
||||
|
||||
export type EntryPoint = 'auto' | 'writer' | 'wordpress' | 'external' | 'manual';
|
||||
|
||||
export interface OptimizationResult {
|
||||
content_id: number;
|
||||
optimizer_version: number;
|
||||
scores_before: {
|
||||
seo_score: number;
|
||||
readability_score: number;
|
||||
engagement_score: number;
|
||||
overall_score: number;
|
||||
};
|
||||
scores_after: {
|
||||
seo_score: number;
|
||||
readability_score: number;
|
||||
engagement_score: number;
|
||||
overall_score: number;
|
||||
};
|
||||
task_id: number | null;
|
||||
success: boolean;
|
||||
}
|
||||
|
||||
export interface AnalysisScores {
|
||||
seo_score: number;
|
||||
readability_score: number;
|
||||
engagement_score: number;
|
||||
overall_score: number;
|
||||
word_count: number;
|
||||
has_meta_title: boolean;
|
||||
has_meta_description: boolean;
|
||||
has_primary_keyword: boolean;
|
||||
internal_links_count: number;
|
||||
}
|
||||
|
||||
export const optimizerApi = {
|
||||
/**
|
||||
* Optimize content (auto-detects entry point based on source)
|
||||
* @param contentId - Content ID to optimize
|
||||
* @param entryPoint - Optional entry point override (default: 'auto')
|
||||
* @returns Optimization result with scores
|
||||
*/
|
||||
optimize: async (contentId: number, entryPoint: EntryPoint = 'auto'): Promise<OptimizationResult> => {
|
||||
return await fetchAPI('/v1/optimizer/optimize/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
content_id: contentId,
|
||||
entry_point: entryPoint,
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Batch optimize multiple content items
|
||||
* @param contentIds - Array of content IDs to optimize
|
||||
* @param entryPoint - Optional entry point override (default: 'auto')
|
||||
* @returns Batch optimization results
|
||||
*/
|
||||
batchOptimize: async (contentIds: number[], entryPoint: EntryPoint = 'auto') => {
|
||||
return await fetchAPI('/v1/optimizer/batch_optimize/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
content_ids: contentIds,
|
||||
entry_point: entryPoint,
|
||||
}),
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Analyze content without optimizing (preview scores)
|
||||
* @param contentId - Content ID to analyze
|
||||
* @returns Analysis scores
|
||||
*/
|
||||
analyze: async (contentId: number): Promise<{ content_id: number; scores: AnalysisScores }> => {
|
||||
return await fetchAPI('/v1/optimizer/analyze/', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ content_id: contentId }),
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user