📜 ⬆️ ⬇️

Facebook or Telegram? History of the Ukrainian .NET Core Community

Hi, Habr! One day, someone who was very interested in .NET Core decided to start blogging. And then he faced the question: "What resource to use?". Existing Facebook and Telegram were completely unsuitable for structuring publications. As a result, it was decided using the same .Net Core to create your website with blackjack and structuring.



I give the word to the author.
')
Since the announcement of the .NET Core, I began to closely monitor this technology. When the first version was released, several of my projects were transferred to this platform. The results pleased us - everything worked stably and even faster than on the classic version of the framework. After a while, I decided to organize an online community of programmers interested in developing for .NET Core. The first platform for communication was Facebook .

After a while, I decided to create another channel in Telegram, where I began to publish links to various news related to the development of .NET Core. After about half a year, I concluded that, although Telegram is very convenient for newsletters, it is absolutely not suitable for searching and structuring publications. Over time, if news on the channel is published often enough, it’s almost impossible to quickly find a publication that you read at least last week.

The Facebook group also did not do a very good job. Therefore, in order to structure the information and make navigation through publications more convenient, I decided to create an aggregator site, eventually called // devdigest.

As a development platform, the .NET Core was naturally taken. The project itself is placed in a public repository on GitHub and everyone can get acquainted with its internal structure and source code.

How the devdigest works // I and the hou tell in this article.

Forming widgets for web pages


The main task of the site is to keep all publications in a convenient form. I took as a sample how the description for the external links of Facebook is generated: for each link, a small widget is formed from the title, photo and short description.

To form a link description, I wrote a small library (the source code of which is available on GitHub , and the library itself is published on nuget.org ). The logic of the library is quite simple and consists in the fact that, upon receiving the link, using the HtmlAgilityPack , an object model of the document is formed (the same DOM tree ) and then, from this model, it is extracted:




Telegram integration


The next step was the organization of cross-posting news in the Telegram channel. The possibility of direct publication in the channel is missing, therefore, it was necessary to create a bot, on behalf of which publications will be posted. How to create a bot is well written here . After creating the bot, you need to add it to the channel with administrator rights, and also get a token:



Everything. Now the bot has the ability to publish posts, and we have the ability to control the bot through the API.

To interact with the bot, I recommend using the official SDK . The code for posting to the channel will look like this:



In addition to posting to Telegram, the site also has the ability to create posts on Facebook, but I’ll tell you about it the next time.

Hosting


I had two options for where to place the project - on one of the servers that I use for commercial projects, or in the Microsoft Azure cloud. The option of placing in the cloud turned out to be preferable for several reasons:


Cognitive Services


Over time, it was decided to display only English in the main page on the publication site, since most of them, and the content alternating in different languages ​​looked rather strange. To implement such filtering, of course, one more combo box could be made in the site administrator interface, with the choice of the publication language. But it is at least banal and not interesting. Especially considering how many ready-made services based on machine learning exist now. So I decided to use the Text Analytics API which is included with Microsoft Azure Cognitive Services. Text Analytics API allows you to extract keywords from the text, as well as determine the language of the transmitted text. This is exactly what I needed.

The prices for the service are quite humane - as we can see, even a free tariff plan provides quite rich possibilities for analyzing the text: extracting key phrases and determining the text language. This is just what we need!

image four

You can work with the Text Analytics API either via the SDK, which is installed as a nuget package , or through the REST API. For myself, I chose the option of working through the REST API using the RestSharp library.

Before making requests to the API, you will need to get the key. You can find it in the corresponding section on the management portal:



Once you have received the key, you can prepare the client:



The API itself is fairly simple and obvious. For example, a request to determine the language of the text would look like this:



The text processing speed is fast enough, so, even though the page is analyzed in two stages (the description, title and image are first retrieved, and then the publication language is analyzed), all the procedures take no more than a few seconds.

Free certificate, SSL, Let's Encrypt and nginx


Since the site is hosted as part of the shared tariff plan, which does not support connecting SSL certificates, but I still wanted to use HTTPS, I decided to use one of my servers on Digital Ocean as a proxy on which the certificate will be configured. I will not describe the procedure for obtaining a certificate through Let's Encrypt, since it is beautifully described, for example, here . The procedure for setting up proxying can also be found quite quickly, but those who are particularly interested in how everything is arranged with us can download the configuration file that is available on GitHub.

Results


And so, what is at the moment? The overall architecture of the project is currently as follows:



From the point of view of information platforms with which integration is set up with us, we can distinguish three different telegram channels, each of which is tied to the corresponding stream on the website:


There is also a Facebook page, which is also tied to the devdigest // net core stream

From the point of view of the site administrator, the UI looks as simple as possible:



The admin panel consists of only 4 input elements:


As a result, in a short period of time and using rather modest resources, I got a fairly simple tool, which at the same time allows us to very much optimize the work on filling several sites.

about the author


Andrei Gubsky - Specialist in software development and architecture. Founder of .NET Core Ukraininan User Group. CTO project Peat TV, developer, IT consultant. Visual Studio and Development Technologies MVP.

Source: https://habr.com/ru/post/347708/


All Articles