{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Paste the block below into the the bottom row of the table in the project_board.md file.\n",
      "\n",
      "<a href=\"https://github.com/bitmonky/mkyNetwork\"><img width=\"278\" src=\"https://denvercoder1-github-readme-stats.vercel.app/api/pin/?username=bitmonky&repo=mkyNetwork&theme=react&bg_color=1F222E&title_color=9ACD32&hide_border=true&icon_color=FF4500&show_icons=false\" alt=\"mkyNetwork\"></a>\n",
      "\n",
      "Paste the block below under the appropriate heading in the main readme.md file.\n",
      "\n",
      "| [mkyNetwork](https://github.com/bitmonky/mkyNetwork) |  ![last commit](https://img.shields.io/github/last-commit/bitmonky/mkyNetwork) ![code size](https://img.shields.io/github/languages/code-size/bitmonky/mkyNetwork) ![commit activity](https://img.shields.io/github/commit-activity/m/bitmonky/mkyNetwork) ![issues](https://img.shields.io/github/issues/bitmonky/mkyNetwork) | An experimental self organizing peer to peer network in node.js |\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def add_your_project(project_url,beta=False):\n",
    "    \"\"\"\n",
    "    add_your_project is a function that adds a project to the list of projects\n",
    "\n",
    "    Parameters\n",
    "\n",
    "    :param project_url: the url of the project\n",
    "    :type project_url: str\n",
    "    :return: None\n",
    "    :rtype: None\n",
    "    \"\"\"\n",
    "    project_name = project_url.split('/')[-1] # negative index to get last\n",
    "    username = project_url.split('/')[-2] # get the username that came before the second to last /\n",
    "    markdown_string = \"\"\"<a href=\"https://github.com/{}/{}\"><img width=\"278\" src=\"https://denvercoder1-github-readme-stats.vercel.app/api/pin/?username={}&repo={}&theme=react&bg_color=1F222E&title_color=9ACD32&hide_border=true&icon_color=FF4500&show_icons=false\" alt=\"{}\"></a>\"\"\".format(username,project_name,username,project_name,project_name)\n",
    "    if beta: #! Note: this is an experimental if section. Should default to the else until this is working.\n",
    "        # summarize the project by getting the readme file and reading just the first paragraph of it and summarizing it.\n",
    "        # step 1 get the text from the readme file using requests and beautiful soup (bs4) libraries and finding the first paragraph.\n",
    "        text = get_text_from_url(project_url)\n",
    "        # the first paragraph is the first line of the text\n",
    "        first_paragraph = text.split('\\n')[0] # split the text by new line and get the first element\n",
    "        # if the first paragraph is less than 100 characters, then it's probably not a good summary, so move on to the next paragraph.\n",
    "        if len(first_paragraph) < 100:\n",
    "            first_paragraph = text.split('\\n')[1]\n",
    "        if len(first_paragraph) < 100:\n",
    "            first_paragraph = text.split('\\n')[2]\n",
    "        if len(first_paragraph) < 100:\n",
    "            first_paragraph = text.split('\\n')[3]\n",
    "        \n",
    "        print(first_paragraph)\n",
    "        # step 2 summarize the text using the summarize function from the gensim library\n",
    "        summary = run_summarization(first_paragraph)\n",
    "        # step 3 add the summary to the markdown string\n",
    "        #markdown_string += \"\"\"<p align=\"center\">{}</p>\"\"\".format(summary)\n",
    "    else:\n",
    "        summary = input(\"Enter a short description of the project: \")\n",
    "    table_row  = \"\"\"| [{}](https://github.com/{}/{}) |  ![last commit](https://img.shields.io/github/last-commit/{}/{}) ![code size](https://img.shields.io/github/languages/code-size/{}/{}) ![commit activity](https://img.shields.io/github/commit-activity/m/{}/{}) ![issues](https://img.shields.io/github/issues/{}/{}) | {} |\"\"\".format(project_name,username,project_name,username,project_name,username,project_name,username,project_name,username,project_name,summary)\n",
    "    \n",
    "    # concatenate the two strings with four line breaks in between them\n",
    "    result =  'Paste the block below into the the bottom row of the table in the project_board.md file.' + '\\n\\n' + markdown_string + '\\n\\n' + 'Paste the block below under the appropriate heading in the main readme.md file.' + '\\n\\n' + table_row\n",
    "    return result\n",
    "\n",
    "\n",
    "project_url = input(\"Enter the url of your project: \")\n",
    "markdown_string = add_your_project(project_url)\n",
    "\n",
    "print(markdown_string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# urls = ['https://github.com/talkygram/webcrawly','https://github.com/BKAmos/DataScience','https://github.com/VanillaLattA/DatascienceShortcuts']\n",
    "\n",
    "# for url in urls:\n",
    "#     markdown_string = create_project_tile(url)\n",
    "#     print(markdown_string)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3.9.6 ('master_env_temp')",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.6"
  },
  "orig_nbformat": 4,
  "vscode": {
   "interpreter": {
    "hash": "666dfdc1c3434f60b2f64fdb13e0b185df8f5878ddae1a39c75e1eb2af091f89"
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
