Lexi Yin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 网站女工-Milestone3 Figma: https://www.figma.com/file/Su6b6XkaDggRzC0oyCd8j0/SnapFoodie?type=design&node-id=0%3A1&mode=design&t=j3bbhcIrny2BYQJT-1 Product Overview Document: https://docs.google.com/document/d/1MtoCvEl9HJjrIs90tyWB2WQ24ed4h3TetRE5NO4RO0w/edit?usp=sharing API Doc: https://docs.google.com/document/d/1yfQByX-VIOPS_NB22bNHsw-zsqubIMew8yhunoWwIco/edit?usp=sharing 大家都太棒了! # Todo 1. [Lexi] delete console.log from Sophie's code, complete implementation for frontend for edit comment ✅ 2. [Lexi] comment - 😎 change text to a form, sophie's tired ✅ 3. [Cindy] update Figma after collection's done 4. [Cindy] add 3rd party API usage 5. [Cindy] answer part 3, everyone can help 6. [Someone] Flashing Issue due to Loading # Class Note for Milestone 3 这个作业的重点/需要注意的地方。 ## Highlight this project (Apr 8) * Group work is optional * github上需要看到每个人的commitment * Each member of the team is responsible for at least 1 feature that creates, reads, and updates some data. * 需要有CRUD -- 每个人都得有,小组中的每个成员都需要提交自己的feature -- 他强调了feature,煞笔 * 接下来几节课是用Firebase来host我们的application * 3 components * **Part 1 - Prototype -- Figma (Squares on the page is enough)** * **"What is your app, and what does it do?"** * Free to use Figma Template but you need to jot it down. * Part1 Submission: - Wifeframe (Figma link). - 1-page product overview document describing the features of your app idea, use cases, how features are used on each page. - Exceptional -- 有点**style**的prototype * **Part 2 - Build it** * 要有log-in功能 ✅ * 数据库可以用Firebase Firestore ✅ * You should be able to save user's data and display it back to them * Part 2 Submission: * 老师要看git commit记录打分 (强调了很多次) * (如果用Firestore) Submit a screenshot showing some of the data in your Firestore Collection. * 需要deploy,可以用firebase,submit the **public URL** * Exceptional(10分) -- 数据需要用有点复杂(maybe多个表,maybe some relational data), 除了用于身份验证和数据的API,你还可以与除了Authentic之外的任何第三方API集成 * **Part 3 - Run It** * deploy完了后要回答问题 一共有 7 个 (类似milestone 1 我们做过的) ========================================== ## Recipe Instgram Module & Features * User Management (User Information 的CRUD -- 直接用Milestone 2的改改) * Recipe Card (样式整成intgram card,也可以CRUD) * **Member 1: 菜谱创建与管理** - Landing Page - Create Recipe - Edit Recipe - Recipe Detail - User创建新的菜谱(上传图片、输入成分、描述做法等)。 - User查看自己创建的菜谱列表。 - User更新自己的菜谱。 - User删除自己的菜谱。 * **Member 2: 用户评论与互动** - Recipe Detail's Comment Sections - Notification Page * 用户可以对菜谱发表评论。 * 用户可以查看菜谱下的所有评论。 * 用户可以编辑或删除自己的评论。 * **Member 3: 个人收藏** - Connect the collection icon from the Recipe Detail Page - Collection Page - Search Page * **创建**:添加收藏。 * **读取**:查看收藏和历史记录。 * **更新**:更新收藏状态(比如取消收藏)。 * **删除**:从收藏中删除。 ## ChatGPT 生成的 # Database Collections and Member Responsibilities ## Database Collections: 1. **Recipes Collection** - **Fields**: `recipe_id`, `user_id` (reference to Users collection), `title`, `description`, `ingredients`, `steps`, `images`, `tags`, `timestamp`. 2. **Users Collection** - **Fields**: `user_id`, `username`, `email`, `profile_image`, `bio`, `favorites` (array of `recipe_ids`), `recent_views` (array of `recipe_ids`). 3. **Comments Collection** - **Fields**: `comment_id`, `recipe_id` (reference to Recipes collection), `user_id` (reference to Users collection), `text`, `timestamp`. 4. **Notifications Collection** - **Fields**: `notification_id`, `user_id` (reference to Users collection), `message`, `link` (URL or internal link to the trigger event), `timestamp`, `read_status`. ## End Points `/`: Landing Page, welcome page ### User End Points ``/accounts/signup/ [get, post]``: Register a new user ``/accounts/login/ [get, post]``: Log in user and get and cache an authentication token ``/accounts/logout/ [get]``: Log out user and delete authentication token from cookie ``/accounts/profile/view/ [get]``: View current user profile ``/accounts/profile/edit/ [get, post]``: Edit current user profile ``/accounts/changepassword/ [get, post]``: Change user password ### Recipe Endpoints: ``/recipe/create/ [get, post]``: For user to create a recipe. ``/recipe/<property_id>/edit/ [patch, put]``: For owner to edit a recipe ``/recipe/<property_id>/detail/ [get]``: Anyone can view a recipe detail ``/recipe/<property_id>/delete/ [delete]``: For owner to delete a recipe ``/recipe/list/ [get]``: For user to see all his/her recipe ``/recipe/search/ [get]``: For any user to search for a recipe. ### Comments Endpoints: ``/comments/recipe/<recipe_id>/ [get]``: List all comments of a recipe. ``/comments/recipe/<recipe_id>/ [post]``: For a user to add a new comment on a recipe ``/comments/recipe/<recipe_id>/<comment_id>/ [get]``: To view a recipe comments. ``/comments/recipe/<recipe_id>/<comment_id>/ [post]``: To reply a recipe comments. ### Notifications Endpoints: ``/notifications/ [get]``: List all notifications for a user. ``/notifications/ [post]``: Create a notification for a user. ``/notifications/<notification_id> [get]``: Mark a notification as read. # Backend Setup 跑起来需要 ```bash= firebase init emulators # 安装emulator -- 相当于模拟已经deploy上去了的情况 firebase emulators:start --only functions ``` 在functions下面建file ```javascript= // functions/hellocindy.js const functions = require("firebase-functions"); // HTTP 请求处理函数 exports.handler = functions.https.onRequest((request, response) => { response.json({ message: "Hello from Cindy!" }); }); ``` 在functions/index.js里claim一下你有这个东西 ```javascript= const hellocindy = require("./hellocindy"); exports.helloCindy = hellocindy.handler; ``` --- # Firebase admin setup 在你提供的项目架构中,如果你打算使用Firebase Admin SDK来管理Firebase服务(如认证、数据库等),我建议在`lib/firebase`目录下创建一个新的文件用于配置和初始化Firebase Admin SDK。这样可以保持代码的组织性和可维护性。下面是具体的步骤: ### 1. 创建一个新的文件来初始化Firebase Admin SDK 在`lib/firebase`目录下,你可以创建一个名为`admin.js`的文件。这个文件将用于配置和初始化Firebase Admin SDK。代码如下: ```jsx const admin = require('firebase-admin'); const serviceAccount = require('../path/to/service-account-file.json'); // 替换为实际路径 admin.initializeApp({ credential: admin.credential.cert(serviceAccount) }); module.exports = admin; ``` ### 2. 在需要的地方引用此配置 在你的应用的其他部分,如`getUser.js`或`fakeRestaurants.js`,当需要访问Firebase服务时,可以引入这个初始化过的`admin`对象。例如: ```jsx const admin = require('./admin'); // 确保路径正确 // 使用admin来访问Firebase服务,如数据库操作 const db = admin.firestore(); ``` ### 3. 确保安全性和路径正确 - **安全性**:确保你的服务账户密钥文件不会被包含在版本控制中(例如`.gitignore`中应包含此密钥文件)。 - **路径**:在初始化Admin SDK时,确保服务账户密钥文件的路径是正确的,相对于你的`admin.js`文件的位置。 ### 4. 使用环境变量 为了进一步提高安全性,你可以考虑使用环境变量来引用服务账户密钥文件,而不是直接在代码中写死。例如,你可以在`.env`文件中设置路径,然后在你的`admin.js`文件中使用`process.env.SOME_ENV_VARIABLE`来获取它。 ### 5. 更新`next.config.js` 如果你使用了环境变量,确保在`next.config.js`中正确地配置了环境变量的加载,使其在应用启动时可用。 通过以上步骤,你可以在你的Next.js项目中有效地集成Firebase Admin SDK,同时保持良好的项目结构和安全性。这种方法也使得以后维护和更新配置更为便捷。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully