diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..f9999c2 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/DjangoBlog"] + path = src/DjangoBlog + url = https://github.com/ETOofficial/DjangoBlog.git diff --git a/doc/.gitkeep b/doc/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/doc/DjangoBlog开源代码的泛读报告.docx b/doc/DjangoBlog开源代码的泛读报告.docx new file mode 100644 index 0000000..33f0743 Binary files /dev/null and b/doc/DjangoBlog开源代码的泛读报告.docx differ diff --git a/doc/images/graph_1.png b/doc/images/graph_1.png new file mode 100644 index 0000000..685a53d Binary files /dev/null and b/doc/images/graph_1.png differ diff --git a/doc/images/graph_2.png b/doc/images/graph_2.png new file mode 100644 index 0000000..80a85a6 Binary files /dev/null and b/doc/images/graph_2.png differ diff --git a/doc/images/graph_3.png b/doc/images/graph_3.png new file mode 100644 index 0000000..c9c3e37 Binary files /dev/null and b/doc/images/graph_3.png differ diff --git a/doc/images/graph_4.png b/doc/images/graph_4.png new file mode 100644 index 0000000..e1a60df Binary files /dev/null and b/doc/images/graph_4.png differ diff --git a/doc/images/graph_5.png b/doc/images/graph_5.png new file mode 100644 index 0000000..8599b68 Binary files /dev/null and b/doc/images/graph_5.png differ diff --git a/doc/images/graph_6.png b/doc/images/graph_6.png new file mode 100644 index 0000000..8c3cc73 Binary files /dev/null and b/doc/images/graph_6.png differ diff --git a/doc/images/graph_7.png b/doc/images/graph_7.png new file mode 100644 index 0000000..946c71b Binary files /dev/null and b/doc/images/graph_7.png differ diff --git a/doc/images/graph_8.png b/doc/images/graph_8.png new file mode 100644 index 0000000..5842dae Binary files /dev/null and b/doc/images/graph_8.png differ diff --git a/doc/mermaid/graph_1.mmd b/doc/mermaid/graph_1.mmd new file mode 100644 index 0000000..dc1c382 --- /dev/null +++ b/doc/mermaid/graph_1.mmd @@ -0,0 +1,22 @@ +graph TD + subgraph DjangoBlog Project + A[accounts] -->|用户体系| B[blog] + A -->|用户登录| C[comments] + A -->|用户绑定| D[oauth] + A -->|用户轨迹| E[owntracks] + + B -->|文章内容| C + B -->|搜索功能| F[djangoblog] + B -->|插件扩展| G[plugins] + B -->|API接口| H[servermanager] + + F -->|搜索引擎| B + F -->|站点地图| B + + G -->|插件功能| B + + H -->|邮件/命令| B + H -->|微信处理| B + + D -->|第三方登录| A + end \ No newline at end of file diff --git a/doc/mermaid/graph_2.mmd b/doc/mermaid/graph_2.mmd new file mode 100644 index 0000000..e18df06 --- /dev/null +++ b/doc/mermaid/graph_2.mmd @@ -0,0 +1,133 @@ +--- +config: + layout: elk +--- + +classDiagram + %% 模型类 + class BlogUser { + +String nickname + +DateTime creation_time + +DateTime last_modify_time + +String source + +get_absolute_url() + +get_full_url() + } + + %% 表单类 + class BlogUserCreationForm { + +CharField password1 + +CharField password2 + +clean_password2() + +save() + } + + class BlogUserChangeForm { + +__init__() + } + + class LoginForm { + +__init__() + } + + class RegisterForm { + +__init__() + +clean_email() + } + + class ForgetPasswordForm { + +CharField new_password1 + +CharField new_password2 + +EmailField email + +CharField code + +clean_new_password2() + +clean_email() + +clean_code() + } + + class ForgetPasswordCodeForm { + +EmailField email + } + + %% 视图类 + class RegisterView { + +form_valid() + } + + class LogoutView { + +get() + } + + class LoginView { + +get_context_data() + +form_valid() + +get_success_url() + } + + class ForgetPasswordView { + +form_valid() + } + + class ForgetPasswordEmailCode { + +post() + } + + %% 认证后端 + class EmailOrUsernameModelBackend { + +authenticate() + +get_user() + } + + %% 应用配置 + class AccountsConfig + + %% 测试类 + class AccountTest + + %% 工具函数 + class utils { + +send_verify_email() + +verify() + +set_code() + +get_code() + } + + %% 继承关系 + BlogUser --|> AbstractUser + BlogUserCreationForm --|> ModelForm + BlogUserChangeForm --|> UserChangeForm + LoginForm --|> AuthenticationForm + RegisterForm --|> UserCreationForm + ForgetPasswordForm --|> Form + ForgetPasswordCodeForm --|> Form + RegisterView --|> FormView + LogoutView --|> RedirectView + LoginView --|> FormView + ForgetPasswordView --|> FormView + ForgetPasswordEmailCode --|> View + EmailOrUsernameModelBackend --|> ModelBackend + AccountsConfig --|> AppConfig + AccountTest --|> TestCase + + %% 关联关系 + BlogUserCreationForm --> BlogUser : 创建 + BlogUserChangeForm --> BlogUser : 修改 + RegisterForm --> BlogUser : 注册 + ForgetPasswordForm --> BlogUser : 重置密码 + RegisterView --> RegisterForm : 使用 + LoginView --> LoginForm : 使用 + ForgetPasswordView --> ForgetPasswordForm : 使用 + ForgetPasswordEmailCode --> ForgetPasswordCodeForm : 使用 + EmailOrUsernameModelBackend --> BlogUser : 认证 + AccountTest --> BlogUser : 测试 + AccountTest --> utils : 测试 + ForgetPasswordForm --> utils : 验证 + ForgetPasswordEmailCode --> utils : 发送邮件 + RegisterView --> utils : 发送邮件 + + %% 依赖关系 + views ..> utils : 导入 + forms ..> BlogUser : 导入 + tests ..> BlogUser : 导入 + tests ..> utils : 导入 + admin ..> BlogUser : 导入 \ No newline at end of file diff --git a/doc/mermaid/graph_3.mmd b/doc/mermaid/graph_3.mmd new file mode 100644 index 0000000..f92ef21 --- /dev/null +++ b/doc/mermaid/graph_3.mmd @@ -0,0 +1,266 @@ +--- +config: + layout: elk +--- + +classDiagram + %% 基础模型类 + class BaseModel { + <> + +id + +creation_time + +last_modify_time + +save() + +get_full_url() + +get_absolute_url()* + } + + %% 核心模型类 + class Article { + +title + +body + +pub_time + +status + +comment_status + +type + +views + +article_order + +show_toc + +body_to_string() + +get_category_tree() + +viewed() + +comment_list() + +get_admin_url() + +next_article() + +prev_article() + +get_first_image_url() + } + + class Category { + +name + +parent_category + +slug + +index + +get_category_tree() + +get_sub_categorys() + } + + class Tag { + +name + +slug + +get_article_count() + } + + class Links { + +name + +link + +sequence + +is_enable + +show_type + } + + class SideBar { + +name + +content + +sequence + +is_enable + } + + class BlogSettings { + +site_name + +site_description + +site_seo_description + +site_keywords + +article_sub_length + +sidebar_article_count + +sidebar_comment_count + +article_comment_count + +show_google_adsense + +google_adsense_codes + +open_site_comment + +global_header + +global_footer + +beian_code + +analytics_code + +show_gongan_code + +gongan_beiancode + +comment_need_review + +clean() + } + + %% 枚举类型 + class LinkShowType { + <> + I, L, P, A, S + } + + %% 表单类 + class BlogSearchForm { + +querydata + +search() + } + + %% 管理类 + class ArticlelAdmin { + +list_display + +list_filter + +actions + +link_to_category() + +get_form() + +get_view_on_site_url() + } + + class TagAdmin + class CategoryAdmin + class LinksAdmin + class SideBarAdmin + class BlogSettingsAdmin + + %% 视图类 + class ArticleListView { + <> + +page_type + +link_type + +get_queryset_cache_key()* + +get_queryset_data()* + +get_queryset() + +get_context_data() + } + + class IndexView + class ArticleDetailView { + +get_context_data() + } + class CategoryDetailView + class AuthorDetailView + class TagDetailView + class ArchivesView + class LinkListView + class EsSearchView + + %% 中间件类 + class OnlineMiddleware { + +__call__() + } + + %% 搜索索引类 + class ArticleIndex { + +text + +get_model() + +index_queryset() + } + + %% Elasticsearch 文档类 + class GeoIp { + +continent_name + +country_iso_code + +country_name + +location + } + + class UserAgentBrowser + class UserAgentOS + class UserAgentDevice + class UserAgent + + class ElapsedTimeDocument { + +url + +time_taken + +log_datetime + +ip + +geoip + +useragent + } + + class ElaspedTimeDocumentManager { + +build_index() + +delete_index() + +create() + } + + class ArticleDocument { + +body + +title + +author + +category + +tags + +pub_time + +status + +comment_status + +type + +views + +article_order + } + + class ArticleDocumentManager { + +create_index() + +delete_index() + +convert_to_doc() + +rebuild() + +update_docs() + } + + %% 应用配置类 + class BlogConfig + + %% 测试类 + class ArticleTest + + %% 继承关系 + BaseModel <|-- Article + BaseModel <|-- Category + BaseModel <|-- Tag + ArticleListView <|-- IndexView + ArticleListView <|-- CategoryDetailView + ArticleListView <|-- AuthorDetailView + ArticleListView <|-- TagDetailView + ArticleListView <|-- ArchivesView + ArticleDetailView --|> DetailView + LinkListView --|> ListView + EsSearchView --|> SearchView + UserAgentOS --|> UserAgentBrowser + + %% 关联关系 + Article --> Category : Foreign Key + Article --> Tag : Many-to-Many + Article --> settings.AUTH_USER_MODEL : Foreign Key + Category --> Category : Self-reference (Parent Category) + Links --> LinkShowType : Uses + ArticleDocument --> Article : Mapping + ElapsedTimeDocument --> GeoIp : Contains + ElapsedTimeDocument --> UserAgent : Contains + UserAgent --> UserAgentBrowser : Contains + UserAgent --> UserAgentOS : Contains + UserAgent --> UserAgentDevice : Contains + + %% 管理关系 + ArticlelAdmin --> Article : 管理 + TagAdmin --> Tag : 管理 + CategoryAdmin --> Category : 管理 + LinksAdmin --> Links : 管理 + SideBarAdmin --> SideBar : 管理 + BlogSettingsAdmin --> BlogSettings : 管理 + + %% 视图与模型关系 + IndexView --> Article : 查询 + ArticleDetailView --> Article : 详情 + CategoryDetailView --> Category : 查询 + AuthorDetailView --> Article : 查询 + TagDetailView --> Tag : 查询 + ArchivesView --> Article : 查询 + LinkListView --> Links : 查询 + + %% 搜索关系 + ArticleIndex --> Article : 索引 + BlogSearchForm --> SearchForm : 继承 + + %% 文档管理关系 + ArticleDocumentManager --> ArticleDocument : 管理 + ElaspedTimeDocumentManager --> ElapsedTimeDocument : 管理 + + %% 测试关系 + ArticleTest --> Article : 测试 + ArticleTest --> Category : 测试 + ArticleTest --> Tag : 测试 + ArticleTest --> SideBar : 测试 + ArticleTest --> Links : 测试 diff --git a/doc/mermaid/graph_4.mmd b/doc/mermaid/graph_4.mmd new file mode 100644 index 0000000..0c5467b --- /dev/null +++ b/doc/mermaid/graph_4.mmd @@ -0,0 +1,77 @@ +--- +config: + layout: elk +--- + +classDiagram + %% 模型类 + class Comment { + +body + +creation_time + +last_modify_time + +is_enable + +__str__() + } + + %% 表单类 + class CommentForm { + +parent_comment_id + } + + %% 视图类 + class CommentPostView { + +dispatch() + +get() + +form_invalid() + +form_valid() + } + + %% 管理类 + class CommentAdmin { + +list_display + +list_filter + +actions + +link_to_userinfo() + +link_to_article() + } + + %% 应用配置类 + class CommentsConfig + + %% 测试类 + class CommentsTest + + %% 工具函数 + class utils { + +send_comment_email() + } + + %% 继承关系 + CommentForm --|> ModelForm + CommentPostView --|> FormView + CommentAdmin --|> ModelAdmin + CommentsConfig --|> AppConfig + CommentsTest --|> TransactionTestCase + + %% 关联关系 + Comment --> AUTH_USER_MODEL : author + Comment --> Article : article + Comment --> Comment : parent_comment + CommentForm --> Comment : create + CommentPostView --> CommentForm : use + CommentPostView --> Comment : create + CommentAdmin --> Comment : manage + CommentsTest --> Comment : test + + %% 依赖关系 + CommentPostView ..> BlogUser : import + CommentPostView ..> Article : import + CommentsTest ..> BlogUser : import + CommentsTest ..> Article : import + CommentsTest ..> Category : import + utils ..> Comment : import + CommentAdmin ..> Comment : import + + %% 方法调用关系 + CommentPostView --> utils : possible_call + CommentsTest --> utils : test_call diff --git a/doc/mermaid/graph_5.mmd b/doc/mermaid/graph_5.mmd new file mode 100644 index 0000000..9baa1d3 --- /dev/null +++ b/doc/mermaid/graph_5.mmd @@ -0,0 +1,264 @@ +--- +config: + layout: elk +--- +classDiagram + %% 管理站点类 + class DjangoBlogAdminSite { + +site_header + +site_title + +has_permission() + } + + %% 应用配置类 + class DjangoblogAppConfig { + +ready() + } + + %% 信号处理器 + class blog_signals { + <> + +send_email_signal + +oauth_user_login_signal + +send_email_signal_handler() + +oauth_user_login_signal_handler() + +model_post_save_callback() + +user_auth_callback() + } + + %% 搜索引擎相关类 + class ElasticSearchBackend { + +manager + +search() + +get_suggestion() + +_create() + +_delete() + +_rebuild() + +update() + +remove() + +clear() + } + + class ElasticSearchQuery { + +_convert_datetime() + +clean() + +build_query_fragment() + +get_count() + +get_spelling_suggestion() + } + + class ElasticSearchModelSearchForm { + +search() + } + + class ElasticSearchEngine + + class WhooshSearchBackend { + +RESERVED_WORDS + +RESERVED_CHARACTERS + +setup() + +build_schema() + +update() + +remove() + +clear() + +delete_index() + +optimize() + +search() + +more_like_this() + +_process_results() + +create_spelling_suggestion() + } + + class WhooshSearchQuery { + +_convert_datetime() + +clean() + +build_query_fragment() + } + + class WhooshEngine + + class WhooshHtmlFormatter { + +template + } + + %% RSS订阅类 + class DjangoBlogFeed { + +feed_type + +description + +title + +link + +author_name() + +author_link() + +items() + +item_title() + +item_description() + +feed_copyright() + +item_link() + +item_guid() + } + + %% 日志管理类 + class LogEntryAdmin { + +list_filter + +search_fields + +list_display + +has_add_permission() + +has_change_permission() + +has_delete_permission() + +object_link() + +user_link() + +get_queryset() + +get_actions() + } + + %% 站点地图类 + class StaticViewSitemap { + +priority + +changefreq + +items() + +location() + } + + class ArticleSiteMap { + +changefreq + +priority + +items() + +lastmod() + } + + class CategorySiteMap { + +changefreq + +priority + +items() + +lastmod() + } + + class TagSiteMap { + +changefreq + +priority + +items() + +lastmod() + } + + class UserSiteMap { + +changefreq + +priority + +items() + +lastmod() + } + + %% 蜘蛛通知类 + class SpiderNotify { + <> + +baidu_notify() + +notify() + } + + %% 测试类 + class DjangoBlogTest + + %% 工具类 + class CommonMarkdown { + <> + +_convert_markdown() + +get_markdown_with_toc() + +get_markdown() + } + + %% 设置类(配置) + class settings { + <> + +INSTALLED_APPS + +MIDDLEWARE + +DATABASES + +HAYSTACK_CONNECTIONS + +CACHES + +LOGGING + } + + %% URL配置 + class urls { + <> + +urlpatterns + +handler404 + +handler500 + +handle403 + } + + %% WSGI配置 + class wsgi { + <> + +application + } + + %% 继承关系 + DjangoBlogAdminSite --|> AdminSite + DjangoblogAppConfig --|> AppConfig + ElasticSearchBackend --|> BaseSearchBackend + ElasticSearchQuery --|> BaseSearchQuery + ElasticSearchEngine --|> BaseEngine + WhooshSearchBackend --|> BaseSearchBackend + WhooshSearchQuery --|> BaseSearchQuery + WhooshEngine --|> BaseEngine + WhooshHtmlFormatter --|> HtmlFormatter + DjangoBlogFeed --|> Feed + LogEntryAdmin --|> ModelAdmin + StaticViewSitemap --|> Sitemap + ArticleSiteMap --|> Sitemap + CategorySiteMap --|> Sitemap + TagSiteMap --|> Sitemap + UserSiteMap --|> Sitemap + DjangoBlogTest --|> TestCase + + %% 关联关系 + DjangoBlogAdminSite --> ArticlelAdmin : 注册 + DjangoBlogAdminSite --> CategoryAdmin : 注册 + DjangoBlogAdminSite --> TagAdmin : 注册 + DjangoBlogAdminSite --> LinksAdmin : 注册 + DjangoBlogAdminSite --> SideBarAdmin : 注册 + DjangoBlogAdminSite --> BlogSettingsAdmin : 注册 + DjangoBlogAdminSite --> CommandsAdmin : 注册 + DjangoBlogAdminSite --> EmailSendLogAdmin : 注册 + DjangoBlogAdminSite --> BlogUserAdmin : 注册 + DjangoBlogAdminSite --> CommentAdmin : 注册 + DjangoBlogAdminSite --> OAuthUserAdmin : 注册 + DjangoBlogAdminSite --> OAuthConfigAdmin : 注册 + DjangoBlogAdminSite --> OwnTrackLogsAdmin : 注册 + DjangoBlogAdminSite --> SiteAdmin : 注册 + DjangoBlogAdminSite --> LogEntryAdmin : 注册 + + ElasticSearchBackend --> ArticleDocumentManager : 使用 + ElasticSearchModelSearchForm --> ElasticSearchBackend : 配置 + WhooshSearchBackend --> ChineseAnalyzer : 使用 + + blog_signals --> Comment : 信号处理 + blog_signals --> OAuthUser : 信号处理 + blog_signals --> LogEntry : 信号处理 + blog_signals --> EmailSendLog : 记录 + + DjangoBlogFeed --> Article : 获取内容 + ArticleSiteMap --> Article : 映射 + CategorySiteMap --> Category : 映射 + TagSiteMap --> Tag : 映射 + UserSiteMap --> Article : 映射 + + %% 依赖关系 + DjangoblogAppConfig ..> plugin_manage.loader : 导入 + blog_signals ..> comments.utils : 导入 + blog_signals ..> djangoblog.utils : 导入 + blog_signals ..> djangoblog.spider_notify : 导入 + ElasticSearchBackend ..> blog.documents : 导入 + WhooshSearchBackend ..> jieba.analyse : 导入 + utils ..> bleach : 导入 + utils ..> markdown : 导入 + + %% 配置关系 + settings --> INSTALLED_APPS : 包含所有应用 + settings --> MIDDLEWARE : 包含中间件 + urls --> admin_site : 包含管理路由 + urls --> blog.urls : 包含博客路由 + urls --> comments.urls : 包含评论路由 + urls --> accounts.urls : 包含账户路由 + urls --> oauth.urls : 包含OAuth路由 + urls --> servermanager.urls : 包含服务器管理路由 + urls --> owntracks.urls : 包含位置跟踪路由 \ No newline at end of file diff --git a/doc/mermaid/graph_6.mmd b/doc/mermaid/graph_6.mmd new file mode 100644 index 0000000..75c4f0b --- /dev/null +++ b/doc/mermaid/graph_6.mmd @@ -0,0 +1,194 @@ +--- +config: + layout: elk +--- +classDiagram + %% Models + class OAuthUser { + +ForeignKey author + +CharField openid + +CharField nickname + +CharField token + +CharField picture + +CharField type + +CharField email + +TextField metadata + +DateTimeField creation_time + +DateTimeField last_modify_time + +__str__() + } + + class OAuthConfig { + +CharField type + +CharField appkey + +CharField appsecret + +CharField callback_url + +BooleanField is_enable + +DateTimeField creation_time + +DateTimeField last_modify_time + +clean() + +__str__() + } + + %% Admin Classes + class OAuthUserAdmin { + +search_fields + +list_per_page + +list_display + +list_display_links + +list_filter + +readonly_fields + +get_readonly_fields() + +has_add_permission() + +link_to_usermodel() + +show_user_image() + } + + class OAuthConfigAdmin { + +list_display + +list_filter + } + + %% Forms + class RequireEmailForm { + +EmailField email + +IntegerField oauthid + +__init__() + } + + %% Views + class RequireEmailView { + +form_class + +template_name + +get() + +get_initial() + +get_context_data() + +form_valid() + } + + %% OAuth Manager Classes + class BaseOauthManager { + <> + +AUTH_URL + +TOKEN_URL + +API_URL + +ICON_NAME + +access_token + +openid + +is_access_token_set + +is_authorized + +get_authorization_url() + +get_access_token_by_code() + +get_oauth_userinfo() + +get_picture() + +do_get() + +do_post() + +get_config() + } + + class ProxyManagerMixin { + +proxies + +do_get() + +do_post() + } + + class WBOauthManager { + +client_id + +client_secret + +callback_url + +get_authorization_url() + +get_access_token_by_code() + +get_oauth_userinfo() + +get_picture() + } + + class GoogleOauthManager { + +client_id + +client_secret + +callback_url + +get_authorization_url() + +get_access_token_by_code() + +get_oauth_userinfo() + +get_picture() + } + + class GitHubOauthManager { + +client_id + +client_secret + +callback_url + +get_authorization_url() + +get_access_token_by_code() + +get_oauth_userinfo() + +get_picture() + } + + class FaceBookOauthManager { + +client_id + +client_secret + +callback_url + +get_authorization_url() + +get_access_token_by_code() + +get_oauth_userinfo() + +get_picture() + } + + class QQOauthManager { + +client_id + +client_secret + +callback_url + +get_authorization_url() + +get_access_token_by_code() + +get_open_id() + +get_oauth_userinfo() + +get_picture() + } + + %% Test Classes + class OAuthConfigTest { + +setUp() + +test_oauth_login_test() + } + + class OauthLoginTest { + +setUp() + +init_apps() + +get_app_by_type() + +test_weibo_login() + +test_google_login() + +test_github_login() + +test_facebook_login() + +test_qq_login() + +test_weibo_authoriz_login_with_email() + +test_weibo_authoriz_login_without_email() + } + + %% Exception Class + class OAuthAccessTokenException { + <> + } + + %% Relationships + OAuthUserAdmin --> OAuthUser : 管理 + OAuthConfigAdmin --> OAuthConfig : 管理 + + RequireEmailView --> RequireEmailForm : 使用 + + BaseOauthManager <|-- WBOauthManager : 继承 + BaseOauthManager <|-- QQOauthManager : 继承 + + BaseOauthManager <|-- GoogleOauthManager : 继承 + ProxyManagerMixin <|.. GoogleOauthManager : 混入 + + BaseOauthManager <|-- GitHubOauthManager : 继承 + ProxyManagerMixin <|.. GitHubOauthManager : 混入 + + BaseOauthManager <|-- FaceBookOauthManager : 继承 + ProxyManagerMixin <|.. FaceBookOauthManager : 混入 + + BaseOauthManager --> OAuthUser : 创建 + BaseOauthManager --> OAuthConfig : 配置依赖 + + OAuthConfigTest --> OAuthConfig : 测试 + OauthLoginTest --> BaseOauthManager : 测试 + OauthLoginTest --> OAuthConfig : 测试 + OauthLoginTest --> OAuthUser : 测试 \ No newline at end of file diff --git a/doc/mermaid/graph_7.mmd b/doc/mermaid/graph_7.mmd new file mode 100644 index 0000000..277283c --- /dev/null +++ b/doc/mermaid/graph_7.mmd @@ -0,0 +1,71 @@ +--- +config: + layout: elk +--- +classDiagram + %% Models + class OwnTrackLog { + +CharField tid + +FloatField lat + +FloatField lon + +DateTimeField creation_time + +__str__() + } + + %% Admin Classes + class OwnTrackLogsAdmin { + # 空管理类,使用默认配置 + } + + %% App Config + class OwntracksConfig { + +name + } + + %% Test Classes + class OwnTrackLogTest { + +setUp() + +test_own_track_log() + } + + %% Views (作为功能模块表示) + class ViewFunctions { + <> + +manage_owntrack_log() + +show_maps() + +show_log_dates() + +convert_to_amap() + +get_datas() + } + + %% URL Patterns + class URLConfig { + <> + +logtracks + +show_maps + +get_datas + +show_dates + } + + %% External Dependencies + class BlogUser { + <> + +create_superuser() + } + + class AMapAPI { + <> + +坐标转换服务 + } + + %% Relationships + OwnTrackLogsAdmin --> OwnTrackLog : 管理 + OwnTrackLogTest --> OwnTrackLog : 测试 + OwnTrackLogTest --> BlogUser : 创建测试用户 + + ViewFunctions --> OwnTrackLog : 创建/查询 + ViewFunctions --> AMapAPI : 调用坐标转换 + + URLConfig --> ViewFunctions : 路由映射 + + OwntracksConfig ..> OwnTrackLog : 应用配置 \ No newline at end of file diff --git a/doc/mermaid/graph_8.mmd b/doc/mermaid/graph_8.mmd new file mode 100644 index 0000000..83f1598 --- /dev/null +++ b/doc/mermaid/graph_8.mmd @@ -0,0 +1,155 @@ +--- +config: + layout: elk +--- +classDiagram + %% Models + class commands { + +CharField title + +CharField command + +CharField describe + +DateTimeField creation_time + +DateTimeField last_modify_time + +__str__() + } + + class EmailSendLog { + +CharField emailto + +CharField title + +TextField content + +BooleanField send_result + +DateTimeField creation_time + +__str__() + } + + %% Admin Classes + class CommandsAdmin { + +list_display + } + + class EmailSendLogAdmin { + +list_display + +readonly_fields + +has_add_permission() + } + + %% WeChat Robot Components + class MemcacheStorage { + +prefix + +cache + +is_available + +key_name() + +get() + +set() + +delete() + } + + class MessageHandler { + +message + +session + +userid + +userinfo + +is_admin + +is_password_set + +save_session() + +handler() + } + + class WxUserInfo { + +isAdmin + +isPasswordSet + +Count + +Command + } + + %% External API Classes + class BlogApi { + <> + +search_articles() + +get_category_lists() + +get_recent_articles() + } + + class CommandHandler { + <> + +run() + +get_help() + } + + class ChatGPT { + <> + +chat() + } + + class WeRoBot { + <> + +token + +config + +filter() + +handler() + } + + %% Test Classes + class ServerManagerTest { + +setUp() + +test_chat_gpt() + +test_validate_comment() + } + + %% App Config + class ServermanagerConfig { + +name + } + + %% URL Configuration + class URLConfig { + +robot + } + + %% External Models (for testing) + class BlogUser { + <> + +create_superuser() + } + + class Category { + <> + } + + class Article { + <> + +title + +body + +get_full_url() + } + + %% Relationships + CommandsAdmin --> commands : 管理 + EmailSendLogAdmin --> EmailSendLog : 管理 + + MemcacheStorage ..> WeRoBot : 会话存储实现 + MessageHandler o-- WxUserInfo : 组合 + MessageHandler --> CommandHandler : 使用 + MessageHandler --> ChatGPT : 使用 + + WeRoBot --> MessageHandler : 消息处理 + WeRoBot --> BlogApi : 博客API调用 + WeRoBot --> MemcacheStorage : 会话存储 + + %% Robot Filter Functions + WeRoBot ..> search : 注册过滤器 + WeRoBot ..> category : 注册过滤器 + WeRoBot ..> recents : 注册过滤器 + WeRoBot ..> help : 注册过滤器 + WeRoBot ..> weather : 注册过滤器 + WeRoBot ..> idcard : 注册过滤器 + + %% Test Relationships + ServerManagerTest --> commands : 测试 + ServerManagerTest --> MessageHandler : 测试 + ServerManagerTest --> CommandHandler : 测试 + ServerManagerTest --> BlogUser : 测试依赖 + ServerManagerTest --> Category : 测试依赖 + ServerManagerTest --> Article : 测试依赖 + + URLConfig --> WeRoBot : 路由配置 \ No newline at end of file diff --git a/src/.gitkeep b/src/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/DjangoBlog b/src/DjangoBlog new file mode 160000 index 0000000..df6020c --- /dev/null +++ b/src/DjangoBlog @@ -0,0 +1 @@ +Subproject commit df6020cd44f39affee81f58088380b23a5fb0c96